From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0067.outbound.protection.outlook.com [104.47.32.67]) by dpdk.org (Postfix) with ESMTP id 6730B7CDC for ; Thu, 13 Sep 2018 13:36:05 +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=hnt0wi/NGNKmOjyyqfFATxw0kQH6pW5crgEVNUT6g0M=; b=KDU2kpYV+LIg+UckodtZE+iRM2sFXFkCGYlRlw4ThO2ohbRrVz93hkjkyVClklKf0hF3wXcwA+Lec5v2C3D9g6qy2sb26/vftbEg8xTl6fJOlzPSf0cEi/xjbK/g0gS3U2i/SIUT1/c9PXDIH7j9dzv6+Ej3zNnEpSEn201E4Vo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Igor.Russkikh@aquantia.com; Received: from ubuntubox.rdc.aquantia.com (95.79.108.179) by BLUPR0701MB1650.namprd07.prod.outlook.com (2a01:111:e400:58c6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.15; Thu, 13 Sep 2018 11:36:03 +0000 From: Igor Russkikh To: dev@dpdk.org Cc: pavel.belous@aquantia.com, igor.russkikh@aquantia.com Date: Thu, 13 Sep 2018 14:35:20 +0300 Message-Id: <1536838528-11800-13-git-send-email-igor.russkikh@aquantia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536838528-11800-1-git-send-email-igor.russkikh@aquantia.com> References: <1536838528-11800-1-git-send-email-igor.russkikh@aquantia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.79.108.179] X-ClientProxiedBy: VI1PR0202CA0026.eurprd02.prod.outlook.com (2603:10a6:803:14::39) To BLUPR0701MB1650.namprd07.prod.outlook.com (2a01:111:e400:58c6::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6451af2f-3679-4609-8e8c-08d6196d169f X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB1650; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 3:BDwaK7Xh/aVK4XTSNjtCthrCxluuA7yldYgP+wwk+yKI4pzForbqD3C9WFVAa27KXBIHVUPfLMqzNkuBxe16amR5PsTHTgTybqwI9a+KQieCWmcWDB1PV9l3YM7JnmN+WfE8StDG1d7ev4yZM/G36q6wNEsPSXTmW2CueOEbzMlZSBGlIxoMdqmglGXL5qq65cr8+gDYjC75y3khnp+DnJASXIcMfMgeBsmZ805mP9hzMq470ZWLU+DgFAz1BDX9; 25:hnPo3vasEv9etwFNczjpTjt2l5G+YsDIHEaQdF8aa+0tYxITIS6JTBvPfN2ltPFhKs0AQFHx+Jw0H1A86a2slxMYjVp44PwlM1PsYG+66EEBaxTTjbUV3W2KTaMk0jIjykBurWSfGnTwVmrmZYVGnlSfB99LbV94zugJBC4Tm5WkDz9qppHMZhmACspVBbixftkipTO3ZRi81+Fqg+aJzp4Hedr2i7DozOWJARv32XE+nTfuM1iJljPcDWqPJYR4RXy4NrBnItp3CUP6tX6FWZGEx3wS6oc8r1kMbj40P4zmDH0NmFB/t+tpjYba8g4yYN6P4o0HgBsYkgoaLvoo+709U8Alxbz5k7Vd05Haz0Y=; 31:3ItEAPm3dI0cD/zbf6baQmvjKBF5sIdiwQp7p8C9fDxcUBL1DXkQfUA1E3Knf1WZflpBtQvg9VD3vHVFiIAoSVrvdhNtrtnBqu9bpH/FQZjDc1jVgDuKyLMauU59kd1NZjgVw+g5dWhH56vMQ/GJSxK4CnJ6VCNqSopqJ7CU5lHAOYgLPfSCdFlE/nrYFIM6iPplsYU3/vmgMNDczq5G0KVJJG5VOFN0pSx4UZzEQII= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1650: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 20:0Wi/1MaKUffWSq1QwczvLl7J3ibKc39Awg0pRgmexca12naaY2DAoqd3knh2Hh8WJiZ8q4xv2NMM3Zr4ag0frZH0feV8FPgKH6zidqKgaLuFincRPEHq/5h1gKUQDz3LD98xIG0zp3PlepHpPufLRa4MoYAcPqku6Em/zgzQ/2zT0EpsGuAYekKCWws+46bt+s8n0Q2GV5nZerqoHuN5mcaV19r3EUAyy+pJqPBZCtIS7Zx92Z/u2lULBdltyTf7zANn+lfzIV6uFfFV9bHKNxnijegs+goyxc3/hdZyqMD1WgX4rcUT/V5rgr0+REBTkUQLOaJ1GgNWLYtg9PvUDYIDeRJiZwi3gbiok6P8Fb9oCOs84QQ2Rio4nY7c/kZemNsOFeFgQ2BiGw79IhZ4QTPa702323U/8uONc5NtC9/MNcXaS6HvJB8eWAmCVNOJ+E/oAIdUNZnOmdyneXlb+svUxkFmPtYCZ3zmxPjTVPXWwJuat0UTK8TRexBCF1KM; 4:nCkmrcPp5fuyMNCZaiNcncR5Y7MWxTc2SwydykEE+5q44zuIhqdU4cs4lOh3KVumFd6YW/4qQ+ohnkW8kSUw1DDfTVQvq03GVWX9Z9ClnHIoNusFBHx61/wW3a/ynncYL/IopRyoOvhZjy8RpLTo2WNMI5zjwK9Y6EqIRrd+zzkQnR+1AhhdS0z5d0j5rT6DYc+cas0Ak/RAZs+3zjfP44HZt4+BS4wgQb/Yfn+gpq8cyBIdKniSFqtQ/mmM/97n0u2N9VrIkX2msmb0ZUZvDQ== 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)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699050); SRVR:BLUPR0701MB1650; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1650; X-Forefront-PRVS: 07943272E1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39840400004)(366004)(396003)(376002)(136003)(346002)(199004)(189003)(6666003)(6916009)(97736004)(8936002)(68736007)(25786009)(50226002)(81166006)(81156014)(4326008)(107886003)(6486002)(51416003)(2906002)(53936002)(5660300001)(36756003)(86362001)(316002)(52116002)(8676002)(16586007)(7736002)(305945005)(11346002)(446003)(476003)(956004)(47776003)(72206003)(66066001)(44832011)(478600001)(486006)(186003)(26005)(16526019)(14444005)(386003)(48376002)(2351001)(106356001)(2361001)(2616005)(3846002)(105586002)(50466002)(7696005)(6116002)(76176011)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1650; H:ubuntubox.rdc.aquantia.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-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1650; 23:1qAHRKyvbIGJYQ8jPOEbrUTBZf7mLct0eLFZEo0?= =?us-ascii?Q?PxkmLonlXJj/qIkrC/MgxxsNPIKG3Gxbrihsq8Y/TTXHNww/2aEFfHXresK7?= =?us-ascii?Q?DQHu4EYb0S/BNahGQm29bCJzfctG/zVYnlsrUrEN7jMkQHdW71JlTj0SFvoE?= =?us-ascii?Q?QfIZFNosR3ntKx+LivuIMx+TxjAxfqLYIDM4MxBdwq8PisWa/S5ACFvHXeWf?= =?us-ascii?Q?Whv7keYGmkuxUVzLxYWf0EpQemTdbTUbXqoa3uTTClsccRJx7FRg9buzs3/b?= =?us-ascii?Q?rRxx5p9izAoyxKK9QNnrglMJG/uilhAQXE2/MYrHjKzvIVE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8luCgO2ZfSMh+uB3xcTM+YLA11vEhKNFIXWVCh7AC+s/dyn8F6Ce2e3KMfUdIsd7YoeGXJDVERs9Zmts+eQ5qnh13n+mkbI2hngJukYT0wvqTuyIrXQSlRZeLWoWA8ipBx0log=; 7:igM5/nqZ1vaIbXnER4fS5uCQRzmgi+EYJVb+UvPQvar09k/c4s5hpmMsPu9xMLDwKZ9rJLexbxPRDxJDQ8hN1hM3qZ9VVykNvFO2wDdPxyr9X8Q6gD+DI+V+aVMXA1Zv0g3JLDqsRl4lPfQJ+kG3Olw3qVJ1nev/zrCXoBxGSLtbzW7tRGYH3ywkoW/yLE9S0YbK+IrgJUNEJlp93+9tKvrCrrWIUAjh+zHMRfelukVZ86TSKCS8UVVRlGGb2rrC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2018 11:36:03.2241 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6451af2f-3679-4609-8e8c-08d6196d169f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 83e2e134-991c-4ede-8ced-34d47e38e6b1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1650 Subject: [dpdk-dev] [PATCH v2 13/21] net/atlantic: 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, 13 Sep 2018 11:36:06 -0000 From: Pavel Belous Signed-off-by: Igor Russkikh --- drivers/net/atlantic/atl_ethdev.c | 108 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 72acb053d..940fd83d9 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -80,6 +80,19 @@ static int atl_dev_interrupt_action(struct rte_eth_dev *dev, static void atl_dev_interrupt_handler(void *param); +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 bool is_device_supported(struct rte_eth_dev *dev, + struct rte_pci_driver *drv); + +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, @@ -166,6 +179,12 @@ static const struct eth_dev_ops atl_eth_dev_ops = { /* Flow Control */ .flow_ctrl_get = atl_flow_ctrl_get, .flow_ctrl_set = atl_flow_ctrl_set, + + /* MAC */ + .mac_addr_add = atl_add_mac_addr, + .mac_addr_remove = atl_remove_mac_addr, + .mac_addr_set = atl_set_default_mac_addr, + .set_mc_addr_list = atl_dev_set_mc_addr_list, .reta_update = atl_reta_update, .reta_query = atl_reta_query, .rss_hash_update = atl_rss_hash_update, @@ -873,6 +892,95 @@ atl_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) } static int +atl_update_mac_addr(struct rte_eth_dev *dev, uint32_t index, + u8 *mac_addr, bool enable) +{ + struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + unsigned int h = 0U; + unsigned int l = 0U; + int err; + + if (mac_addr) { + h = (mac_addr[0] << 8) | (mac_addr[1]); + l = (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 = 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 = 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 = 0; i < AQ_HW_MULTICAST_ADDRESS_MAX - HW_ATL_B0_MAC_MIN; i++) { + u8 *mac_addr = NULL; + u32 l = 0, h = 0; + + if (i < nb_mc_addr) { + mac_addr = mc_addr_set[i].addr_bytes; + l = (mac_addr[2] << 24) | (mac_addr[3] << 16) | + (mac_addr[4] << 8) | mac_addr[5]; + h = (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) -- 2.13.3.windows.1