From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0048.outbound.protection.outlook.com [104.47.38.48]) by dpdk.org (Postfix) with ESMTP id 0F76F1B5EF for ; Fri, 12 Oct 2018 13:09:45 +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=j0XfASLu+lxxP0ckRsIxiIk1Pfd+70dgrQ6itrwKDGQ=; b=nSP6d7wU+hs3Kvf5ZXabcGjbeMVETySlAGW4715tHTRZeSgpfkESshw4UcV6atOOxPXyzd1JFYo3j+joMd+C9nJr/mczp13HP4kbF+6ABgq7+2QK0CJibMukq1jTnSB5Wf0xQMIPwZ/fSb4mKRYBTYtUQq702DgLlFM4X51WyGo= Received: from BY1PR0701MB1660.namprd07.prod.outlook.com (10.162.110.22) by BY1PR0701MB1627.namprd07.prod.outlook.com (10.162.110.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.22; Fri, 12 Oct 2018 11:09:43 +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; Fri, 12 Oct 2018 11:09:43 +0000 From: Igor Russkikh To: "dev@dpdk.org" CC: Pavel Belous , Igor Russkikh , "ferruh.yigit@intel.com" , Pavel Belous Thread-Topic: [PATCH v6 17/22] net/atlantic: implement MAC address manipulations Thread-Index: AQHUYhwTfWvFyvoSMEu+BPk+XcwjyA== Date: Fri, 12 Oct 2018 11:09:43 +0000 Message-ID: <665da1a6647d9f4e4c4f657605e20b21237fce38.1539338074.git.igor.russkikh@aquantia.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM5PR0701CA0008.eurprd07.prod.outlook.com (2603:10a6:203:51::18) 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; BY1PR0701MB1627; 6:tyeTWji/Fzsl6YPNu0waVjL0Xx9abJeXplOL/viSNkldR2G7uQ3FQXH82IFD5eoTuyD/tpPfXnr6XnscwFrd+pz1ZgQcvOX2fyQYzrn3wauvjd2S4RJ/rCUMX3G/ITugmGUykSU295sksFW6pZxz4PYCz+HHuc2gr2LUyWLDb8+h8FcNyOS8qsnorYtB9Mzx0Uigh3ELpHfWusPTVeIu/H5c0Mxo0amiYvOopABBEvRe1yRaP123Ge99jYL0eKY05fnllMs7+xQCN38Ba0oDzaP+fV/iF3KbMsbhuEGCwBjfqtETEch7KNOD72V+oXzszoAvMomOJd6m3RFKBE3lwNQ/gkLxtm5ig5tt37/s+uTbvtZ5qdN2vYB53AHeGxREN7b/uJYAHE7Dl/F//Jhnm0FiN1AtvwskLz/+Hz3rnOOYrJ23kmHZaJzlB7xEwX3PQsEFMSawPo2UwIRxitcAPncokRw6t0o5KIcKqxmbI7A=; 5:UXpGF6Jlrz5o4FbmNK0ANGWXOnJZD3GMY7ALZg/LsZlanq56ZheSPMOa1pleS75qw428rCyJgLm8MIMGNZmdwfOcJ9o0WuC/Ja4Noh3SZ3sqwIBxpw083EpI0bG9XoB/7YkyZ21fm6DiacdrljkEiVJYPy4kBIjmA3xz5bCBNKI=; 7:RsAhWZR48flf84wJ0IA84//GCr/xknU7ScoB24T6ynGszqVcmre9v1s7cdZUzRwvYgXS0iLqVkvc2agVuyzQE9iWgX0wPjNLsVSKxeQIZwReO+O119gYAIjFbNc56E4SdCgqvM0tPCfd4xHuvZFyaqerI7BePvS4SWzNAIgrP8iGjbMcUPso0d21AFyWSjJzXXE2dgHDI02Fcku0Y+hWfrIljC9BXA1jK33y/uIC1tVRgZXTa9jQp4xR3fSev26p x-ms-office365-filtering-correlation-id: 1369e234-5613-46da-f018-08d630333630 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BY1PR0701MB1627; x-ms-traffictypediagnostic: BY1PR0701MB1627: 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)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991067); SRVR:BY1PR0701MB1627; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1627; x-forefront-prvs: 0823A5777B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(376002)(136003)(39850400004)(396003)(189003)(199004)(186003)(6116002)(486006)(5640700003)(446003)(6436002)(6512007)(53936002)(71200400001)(71190400001)(14454004)(72206003)(316002)(2351001)(44832011)(3846002)(7736002)(305945005)(2906002)(4326008)(6486002)(107886003)(97736004)(26005)(2501003)(102836004)(5250100002)(11346002)(86362001)(575784001)(25786009)(476003)(2616005)(106356001)(54906003)(105586002)(256004)(14444005)(5660300001)(66066001)(81166006)(81156014)(1730700003)(8676002)(478600001)(36756003)(68736007)(6916009)(8936002)(99286004)(386003)(6506007)(118296001)(2900100001)(52116002)(76176011)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1627; H:BY1PR0701MB1660.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: aquantia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 3wETMldwEI0Wnqv6SIXdJQaR1BOKMqMdNDG15JKfZ1wtAiqwwfMlC0oKdMAzLLbIY7u6j5R8ZbO9YlunATaWvEDmK7XbyWQbeCuuMg7jy1FBlFmL7EyoRms7zNOo4zQNcuh7HSuLTTm/ixBrjUosAfuGUyVe0ctZfDOAvUfS+3TGoMg3Kn+/mSxp5lvpcl2x81C9moIaKioPzovI8h2klUwLHcd+b+cNS1ce9htT7L79/3On2lXr7GTyp1Orpg6e14zWh8/uMxvJD/tD3iguJIqVfT8YFg5UkoSEncKRdyZRiI8uY0oFzUBZvUNsquXQVr2ak8rZf8iJa05fTAOjoF3hNky6CmsgRjspvdBmuHA= 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: 1369e234-5613-46da-f018-08d630333630 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Oct 2018 11:09:43.5430 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1627 Subject: [dpdk-dev] [PATCH v6 17/22] net/atlantic: implement 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: Fri, 12 Oct 2018 11:09:45 -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 e86707ea5c0a..1dd3ff87e512 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 6ce4454fe2f3..6cee14b2dcba 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, @@ -229,6 +241,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 @@ -1081,6 +1098,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