From patchwork Tue Apr 23 21:20:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ren X-Patchwork-Id: 1089999 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=fb.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=fb.com header.i=@fb.com header.b="MogJTY+s"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44pv1T02M0z9s3Z for ; Wed, 24 Apr 2019 18:41:32 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727691AbfDXIlb (ORCPT ); Wed, 24 Apr 2019 04:41:31 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:60034 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727247AbfDXIlb (ORCPT ); Wed, 24 Apr 2019 04:41:31 -0400 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3O8fU1H031238 for ; Wed, 24 Apr 2019 01:41:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=Wjeih4drKxvCXgraFNPv3LrPtimhzFKHZMw/UQDDo9g=; b=MogJTY+sxUi5Eixza1waPiWVNAgY9W50Ipk5t5x/0D1m7928+J0c4v6PCyYagX+WePbL rdORfdLL/dJAEVt2nqeQAmDpX4RgW9Uz0wOjuHcrvGxYHlN44ALd1ZWqKXZedmqkGyGR SEWTbVP0TvEVw4VHrdzn5ohFgcud6gEOfWw= Authentication-Results: fb.com; spf=pass smtp.mailfrom=taoren@fb.com Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 2s25j347ct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 24 Apr 2019 01:41:30 -0700 Received: from mx-out.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 24 Apr 2019 01:41:27 -0700 Received: by devvm24792.prn1.facebook.com (Postfix, from userid 150176) id AAAE013BA5DD3; Tue, 23 Apr 2019 14:20:38 -0700 (PDT) Smtp-Origin-Hostprefix: devvm From: Tao Ren Smtp-Origin-Hostname: devvm24792.prn1.facebook.com To: "David S . Miller" , Maxim Mikityanskiy , Bartosz Golaszewski , , , Jakub Kicinski , Samuel Mendoza-Jonas , Joel Stanley , Andrew Jeffery , CC: Tao Ren Smtp-Origin-Cluster: prn1c35 Subject: [PATCH net 1/2] net: add eth_addr_inc in etherdevice.h Date: Tue, 23 Apr 2019 14:20:37 -0700 Message-ID: <20190423212037.1983760-1-taoren@fb.com> X-Mailer: git-send-email 2.17.1 X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-24_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=913 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904240075 X-FB-Internal: deliver Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add eth_addr_inc function in etherdevice.h to increment MAC address. One of the use cases is in ncsi stack, where the host's MAC address needs to be incremented to get BMC's MAC address. Signed-off-by: Tao Ren --- include/linux/etherdevice.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index e2f3b21cd72a..d48e3a724c54 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -448,6 +448,19 @@ static inline void eth_addr_dec(u8 *addr) u64_to_ether_addr(u, addr); } +/** + * eth_addr_inc - Increment the given MAC address + * + * @addr: Pointer to a six-byte array containing Ethernet address to increment + */ +static inline void eth_addr_inc(u8 *addr) +{ + u64 u = ether_addr_to_u64(addr); + + u++; + u64_to_ether_addr(u, addr); +} + /** * is_etherdev_addr - Tell if given Ethernet address belongs to the device. * @dev: Pointer to a device structure