From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680075.outbound.protection.outlook.com [40.107.68.75]) by dpdk.org (Postfix) with ESMTP id 5AA431B45E for ; Thu, 11 Oct 2018 12:35:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=AQUANTIA1COM.onmicrosoft.com; s=selector1-aquantia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0RdCJNuJJTUnoFU3B13/SdNX7A6/18y+ciKUa89ybm0=; b=qXYAmuve3oJY9w22Oik22BrbFrQeym/NmOt5l6bcU3MebIPZ+O5Ciuwm8AixdGAi4vBoWk/jK856CkXfjIdikRV4z3BwfQ1n9AaUnWAqG+BroGhVKKxyU9FIbNvIhGyLXkbZuoeMfFlp85E21LftX8Vf0uTH/2V7bFRueL3hxcI= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1208.namprd07.prod.outlook.com (10.160.105.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.27; Thu, 11 Oct 2018 10:35:37 +0000 Received: from BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::346d:e756:e70e:17]) by BY1PR0701MB1660.namprd07.prod.outlook.com ([fe80::346d:e756:e70e:17%3]) with mapi id 15.20.1228.020; Thu, 11 Oct 2018 10:35:36 +0000 From: Igor Russkikh To: "dev@dpdk.org" CC: Pavel Belous , Igor Russkikh , "ferruh.yigit@intel.com" , Pavel Belous Thread-Topic: [PATCH v5 18/23] net/atlantic: support for MAC address manipulations Thread-Index: AQHUYU4lk7E/wk4fUkuNvuDAAKunRA== Date: Thu, 11 Oct 2018 10:35:36 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR04CA0088.eurprd04.prod.outlook.com (2603:10a6:803:64::23) To BY1PR0701MB1660.namprd07.prod.outlook.com (2a01:111:e400:522a::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [95.79.108.179] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BY1PR0701MB1208; 6:WksrS/9zKtnGK+/A43o5Yk7ubYtWSLyybBHBkInBeOVv+dTN4LEHkZty/v0VDkKZf/h9Dk6R4dA26NznNb114hjuArMbSaEFtIkQrDvMQ8tcugHKrCMWxAR0uVhLt2oLo0aZkt5hRIIbpanFs0vbAqHsvo+bOARAuektygU9wKXHkBjrujKtIjcBN4VR7RzElOCt0T6I5JGv/bXiuf2z5YNZq/z915MU2crOlV59s6B14tjwI0kVpNwralBtPcFWjrcm7DoZqX7XZ2w1/1xIC7NoI35EtmrelU6KwPk9lS4HQYMzzTX42Lv6IcNVwU5BbETyCo0QvwncW6jYrwFXoQF8WWiLpPnQfBkOxSpkiw/u4X3uU16MwXmxPA8HWfF8LLTzOqt2W5edwY5KEjyUi7FLh5btqUOAaekmRaKOKUXGANGVwtfFuM+bwPmEPDcRapdNVdHOPJBvuZC9PDocFCqyWIBeIQtY6uqh/XMEkxY=; 5:Cq7cqnG9KxD9iqKLBP74IdefZTGZTuUN1jTVpDzR7iejDc/LK8vi+cLymhvvj1HJWdQQKft2EELOUFLCEGQH/dNNQbFJIYNbkaneTMAdm+Hls4TY/GIvcIPuDhBZ2zs5ltu+s9XwuGThSCOTDmJ9hqPvogpV594EczUApRCCO5A=; 7:hFryAHZjMYry9zxPxujnMwc/skCUVYnfmpj+DYTytnxsOjCscgHvF32ckaIWkgTSrMRfihAdp9hzn1saQkpdltal+keMBRu36JPeXXzwPA0HVrhPsS+Kycsm2unsRjeRqhTww1YT2BLV0hDPLZvZSoAB1MOde743PFo06+fPWxjc3YuwWP2CeAw8EZrle2x5pmlOcSGIzJDj/V3+4P9sP6VrgWBnQTThc71v2jfKkXNhgp8DzllJWTrzR79xScbc x-ms-office365-filtering-correlation-id: ef8997e9-576f-4d50-abda-08d62f6547ed x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BY1PR0701MB1208; x-ms-traffictypediagnostic: BY1PR0701MB1208: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(149066)(150057)(6041310)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(201708071742011)(7699051); SRVR:BY1PR0701MB1208; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1208; x-forefront-prvs: 08220FA8D6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(39840400004)(346002)(396003)(136003)(366004)(199004)(189003)(26005)(99286004)(72206003)(478600001)(76176011)(14454004)(486006)(256004)(97736004)(14444005)(8676002)(316002)(5660300001)(8936002)(476003)(66066001)(4326008)(305945005)(11346002)(2616005)(71190400001)(6116002)(2351001)(54906003)(86362001)(446003)(6506007)(6916009)(7736002)(386003)(25786009)(105586002)(106356001)(6512007)(2906002)(36756003)(3846002)(71200400001)(102836004)(68736007)(186003)(118296001)(5250100002)(44832011)(2501003)(81166006)(1730700003)(2900100001)(107886003)(52116002)(53936002)(6486002)(6436002)(81156014)(5640700003)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1208; H:BY1PR0701MB1660.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: OIqAHdu8UCf72VZDdg96q7aoBZmIcjYd8MtIavQk4cQajzcX+95qL4Dktr+2Xk0u/v7CwmENu1a49e4dXjwjbDxkG/ZlyJ+LeigC0GpsDaxDZI/Gsh4NBhbmyOJ4VjQkfU5NUZW1Y+wBvy63lDvO9X6jKmPGLwt0VT0lNNEJSOKMqnwH1PufGSIbcdB7galhstCwet5pm+eKE6Q/C2ZZPVAX/QNTBjt2iOcz/EjwThZDDLVIsCLxUNhyd4T96Rlfr/iCnUAb2RyM0w5DnIwRRFdVrW8H8qy+TPvrO+T6M+/Kqvvszqwcmwz5xpe6M6GK/fPmMLil1b6diR+Sh+XgMX7OnIu9eeyH6Z4XxlTYCDo= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef8997e9-576f-4d50-abda-08d62f6547ed X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Oct 2018 10:35:36.9338 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1208 Subject: [dpdk-dev] [PATCH v5 18/23] net/atlantic: support for MAC address manipulations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Oct 2018 10:35:39 -0000 From: Pavel Belous Add support for adding/removing MAC addresses. Signed-off-by: Igor Russkikh Signed-off-by: Pavel Belous --- doc/guides/nics/features/atlantic.ini | 1 + drivers/net/atlantic/atl_ethdev.c | 105 ++++++++++++++++++++++++++++++= ++++ 2 files changed, 106 insertions(+) diff --git a/doc/guides/nics/features/atlantic.ini b/doc/guides/nics/featur= es/atlantic.ini index 40a4ddb4cf74..b3ae6fa27c37 100644 --- a/doc/guides/nics/features/atlantic.ini +++ b/doc/guides/nics/features/atlantic.ini @@ -11,6 +11,7 @@ Queue start/stop =3D Y Jumbo frame =3D Y Promiscuous mode =3D Y Allmulticast mode =3D Y +Unicast MAC filter =3D Y RSS hash =3D Y RSS key update =3D Y RSS reta update =3D Y diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_e= thdev.c index 0645e34df780..804c02c6f978 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -64,6 +64,18 @@ static int atl_dev_interrupt_action(struct rte_eth_dev *= dev, struct rte_intr_handle *handle); static void atl_dev_interrupt_handler(void *param); =20 + +static int atl_add_mac_addr(struct rte_eth_dev *dev, + struct ether_addr *mac_addr, + uint32_t index, uint32_t pool); +static void atl_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index); +static int atl_set_default_mac_addr(struct rte_eth_dev *dev, + struct ether_addr *mac_addr); + +static int atl_dev_set_mc_addr_list(struct rte_eth_dev *dev, + struct ether_addr *mc_addr_set, + uint32_t nb_mc_addr); + /* RSS */ static int atl_reta_update(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, @@ -230,6 +242,11 @@ static const struct eth_dev_ops atl_eth_dev_ops =3D { .flow_ctrl_get =3D atl_flow_ctrl_get, .flow_ctrl_set =3D atl_flow_ctrl_set, =20 + /* MAC */ + .mac_addr_add =3D atl_add_mac_addr, + .mac_addr_remove =3D atl_remove_mac_addr, + .mac_addr_set =3D atl_set_default_mac_addr, + .set_mc_addr_list =3D atl_dev_set_mc_addr_list, .rxq_info_get =3D atl_rxq_info_get, .txq_info_get =3D atl_txq_info_get, =20 @@ -1082,6 +1099,94 @@ atl_flow_ctrl_set(struct rte_eth_dev *dev, struct rt= e_eth_fc_conf *fc_conf) } =20 static int +atl_update_mac_addr(struct rte_eth_dev *dev, uint32_t index, + u8 *mac_addr, bool enable) +{ + struct aq_hw_s *hw =3D ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + unsigned int h =3D 0U; + unsigned int l =3D 0U; + int err; + + if (mac_addr) { + h =3D (mac_addr[0] << 8) | (mac_addr[1]); + l =3D (mac_addr[2] << 24) | (mac_addr[3] << 16) | + (mac_addr[4] << 8) | mac_addr[5]; + } + + hw_atl_rpfl2_uc_flr_en_set(hw, 0U, index); + hw_atl_rpfl2unicast_dest_addresslsw_set(hw, l, index); + hw_atl_rpfl2unicast_dest_addressmsw_set(hw, h, index); + + if (enable) + hw_atl_rpfl2_uc_flr_en_set(hw, 1U, index); + + err =3D aq_hw_err_from_flags(hw); + + return err; +} + +static int +atl_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr, + uint32_t index __rte_unused, uint32_t pool __rte_unused) +{ + if (is_zero_ether_addr(mac_addr)) { + PMD_DRV_LOG(ERR, "Invalid Ethernet Address"); + return -EINVAL; + } + + return atl_update_mac_addr(dev, index, (u8 *)mac_addr, true); +} + +static void +atl_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index) +{ + atl_update_mac_addr(dev, index, NULL, false); +} + +static int +atl_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr) +{ + atl_remove_mac_addr(dev, 0); + atl_add_mac_addr(dev, addr, 0, 0); + return 0; +} + +static int +atl_dev_set_mc_addr_list(struct rte_eth_dev *dev, + struct ether_addr *mc_addr_set, + uint32_t nb_mc_addr) +{ + struct aq_hw_s *hw =3D ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + u32 i; + + if (nb_mc_addr > AQ_HW_MULTICAST_ADDRESS_MAX - HW_ATL_B0_MAC_MIN) + return -EINVAL; + + /* Update whole uc filters table */ + for (i =3D 0; i < AQ_HW_MULTICAST_ADDRESS_MAX - HW_ATL_B0_MAC_MIN; i++) { + u8 *mac_addr =3D NULL; + u32 l =3D 0, h =3D 0; + + if (i < nb_mc_addr) { + mac_addr =3D mc_addr_set[i].addr_bytes; + l =3D (mac_addr[2] << 24) | (mac_addr[3] << 16) | + (mac_addr[4] << 8) | mac_addr[5]; + h =3D (mac_addr[0] << 8) | mac_addr[1]; + } + + hw_atl_rpfl2_uc_flr_en_set(hw, 0U, HW_ATL_B0_MAC_MIN + i); + hw_atl_rpfl2unicast_dest_addresslsw_set(hw, l, + HW_ATL_B0_MAC_MIN + i); + hw_atl_rpfl2unicast_dest_addressmsw_set(hw, h, + HW_ATL_B0_MAC_MIN + i); + hw_atl_rpfl2_uc_flr_en_set(hw, !!mac_addr, + HW_ATL_B0_MAC_MIN + i); + } + + return 0; +} + +static int atl_reta_update(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size) --=20 2.7.4