From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730046.outbound.protection.outlook.com [40.107.73.46]) by dpdk.org (Postfix) with ESMTP id 2A1EF1B1F9 for ; Sat, 29 Sep 2018 12:32:35 +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=cSOhXwExijCam0sm7Wl8W1Mgd1ok7Fxa/T8TE9RikEs=; b=CeMXuc4PxQ7ci9qbcgjRbD0RrtlC0xVVcp88PfMlE2nrdJHF839Co8MmZSvqJTBSBlpaNcS4WligSI6y9yv6dhko6riOze6GKudOXU0TtwXR9g6tlru3gt7QZDAA2vRDRzauhUKmay5D/znOfwcB/kEczUvCfKVQiKLycLng01o= 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.1185.22; Sat, 29 Sep 2018 10:32:27 +0000 From: Igor Russkikh To: dev@dpdk.org Cc: pavel.belous@aquantia.com, igor.russkikh@aquantia.com, Pavel Belous Date: Sat, 29 Sep 2018 13:30:31 +0300 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.79.108.179] X-ClientProxiedBy: VI1P193CA0009.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::19) To BLUPR0701MB1650.namprd07.prod.outlook.com (2a01:111:e400:58c6::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78a79145-0fc9-464f-6112-08d625f6de29 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB1650; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 3:d8Boz7QSORHudwN5n+aTntwmKFQB2rDDu8hRS1ym8olc3wNCdDgPBCwp+Pll2b3/hom+R33NFLiHVxWxiQQ3hq/mCJ2tJwUrqktakmIhPRWEgKPfHHUrKVBl+9WUTYq0XKap8ME9v1D392/qBawkPJ9zyMv9ku0ojFpha4Khvjnzm133Gwi5E+2hSP68Z67FRghcs+zDthgYFHFPWnbWK5h8LlyfjP5RWb+q27pcc187sHwjP/2ScffeORQwkJ2h; 25:cHPBzVfaCqioGixDt2fS1WhgUvqKWrouV/b3+ttjCOA7Pk8ePtCfPkfctkIqbXlCkMCR6xvTJWsESa1iq0oHqzqiDVSeqfJxyjrkJGMHiPtsu6Q5W3FulrjW1+Pa0m6j/FxcyYo7NgtRuLMeEYVO2qEseEql3/ZX/NZObQvXhRyo6uskBcHMNsU5ic5o/BdNP7mq2HFVsZym0lgTM9o8jcRoBU/y7aQdu7c9Zi8apqNwUQRVc5oTqSCad7rYbgYZg2jQTi46zmPoX5JZ+fNH07S6acY6O8ot3AQHPAPJsQNAwxT6XpcLiY1EfwYWqzPHHnKdglA//SKt7+iHvPeLxK9R5lvCbNsarCH8yWrTCf4=; 31:GVNBsrwyTke1pmzoMugk5tPh0OXs+Yn5u2zNdzxKuItv+dPrwGiUnENEm0Ur+toDNHHImISNnxWMTy3ozfZywRuV6niqZ6U4Kx4qyMVdct0I+aYT3OqRtOScsG1oVgs0lBxvTe/llJi3wK0aj5lvsiAMqHZuBR9+ycLj9XwBgJn8n8eJ5VZO3x7YWBNbRNOECu0uEmsUmC3BiITosz692KcQ3pLcEt0sM9zAKU1jvuA= X-MS-TrafficTypeDiagnostic: BLUPR0701MB1650: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB1650; 20:98ksoSRFlMeN9HrVxnPmVu94mG+Ez6LoqFL+EdMnDVPzrChwtOMmuFXcCI/8ulwA30lEAEsrAL8qqmJcWT7r08gW2QdLkWd8H5N+J607U3fOuB1YXuEX9ViLoigqI0pcvt7xpEbVNLiFf6tK7KuUaKP2YLCIscPYmb6nI1P1uSHTRjEQ8YXPK2iA5ajiRaewXu7ygYWd+A/5ekgJ/A17R1P37nVPjowiWJp6EbRvqVvDv7Y7aGS/Qh31Ypdpz/lBZnaE93UZZSUMr8A5D/jBPCNJBPA7+ZjFaZe6+u7xo4id5lUBZE0oRBPI/GL1rVp2B4UOXekO9C/AjUf4hK0tc5p0Mya/V045XTdjkcmKpZqE4Xc0/QxAj7NJ36gvXgAUVBbGM0XBUMp1UmIwHo4VpiVdDNyx+mVFSOY6yFVxL/xB7tEGiSUbmP+s2YSupzEXMmyct5rkzJIANYg/cUKVPGF5j4HulPm/vD/A8PCTq/QkjHn8ewowIf19JMtr8E6e; 4:D8b83jddTK1blmlRoqFtpfJDfUQ1b+Cn+GfddyWK3pa6uL5VSxeoVXwdzFiwx1L7XoXTUHKBR7AH3gXXkHOlRZ0nleCgeR3rQPQiDrfv6MmuLdFP1906gu6kTjN6Z5/fzBhFfSLefIXed5PhVLObINGcd/DwKjhvRybMtaSgCRFOPkWfDtox2aL+vmDLY3p9Jhg3vPVGCVUXGpmWLhXwSqsR142+2nzJA+xXXewfveuAJnqXC4e69/rvet/eWZZlFXaGSEQ9cIvsfRu8SIAvYg== 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)(10201501046)(3002001)(93006095)(93001095)(3231355)(944501410)(52105095)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051); SRVR:BLUPR0701MB1650; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1650; X-Forefront-PRVS: 0810818DA0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(346002)(136003)(396003)(376002)(39850400004)(366004)(189003)(199004)(16526019)(14444005)(446003)(76176011)(2906002)(6916009)(6666003)(97736004)(8676002)(81166006)(81156014)(36756003)(4326008)(316002)(8936002)(50226002)(34290500001)(86362001)(5660300001)(68736007)(16586007)(118296001)(72206003)(3846002)(6116002)(53936002)(386003)(105586002)(6486002)(47776003)(66066001)(486006)(25786009)(305945005)(50466002)(44832011)(956004)(2616005)(26005)(107886003)(52116002)(51416003)(7696005)(186003)(476003)(478600001)(2361001)(7736002)(2351001)(48376002)(106356001)(11346002)(309714004)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1650; H:ubuntubox.rdc.aquantia.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-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB1650; 23:ytxnTUIktLn/aDqTqswXa2GDWHGZFCLzDSnVEKs?= =?us-ascii?Q?3cdQ4haAPyIDqMnvbqQASmWOUPsy1waLzPX5X2aMCrrIMDLuPoPLFCjTMYRe?= =?us-ascii?Q?CEuhIhJg8Nil7C2mHPu4CGTKiPoMnvpWxP2po5j6zrwIydX2WMAPJNTy9IID?= =?us-ascii?Q?aS2JUbD9y8fq8XO7D8z7bvqHnnr4Hx+vLbeA/U77xQ4O8M6qPm31U43R53ji?= =?us-ascii?Q?LWekqBt6rFGbYFrFaroXQjuGYm1hlBFWnyILZbCpNTCXyToUc5fNv0Nd1qQx?= =?us-ascii?Q?0pj1n1XOIGKx//jFrdqsiXQil2lP5xCSqY30++3idsDeTnS0UTh5LcIZUeao?= =?us-ascii?Q?AbPiTX9wxdLuTRQ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ljf3KYxkYNq60bXuyWRTD8IR868xyRNVA2txNyJgh2rPWBdt+AU28cfnUqr7x6LMxmfkoll1X3zkoc2IjQQ==; 5:M6aOsK1YjA7eFkvpXt7cqfot208GgEPTnk3VEx5KhsxOdmHYaD5RMe+cKol/ZRts06qtTH7T0jcTFUTdrrWQrm1fMZkPbisKh8emsuiAkKlWc47UIBXLselqTPp4a4oGaKLMvxpfPki7cfQHh0JjVWIdMJlXGdazwHluEaA/zqE=; 7:+nfDsayPUCJDyVYt7RWJuZIkXnjU0f2XK3WkNA/O0jKjr46yBw1xckwXEZzGkfWNxmJTMWtAIohntkAT+dHq5BiHIv0VPjSXOiYIoItgdcAEuxnU/qo6IyflQ/pbJv1vxjWDn+ARlUPbOt7ByIUeLnyVa7XJYXqgBYo6NGWuEvp7M8QkGtEIvuCfaxOZ0ex9qc8L865O8D7olIhI/f48KPYQtJ5m2dr0uZvF4DQKPu5q7VzOLoND5cegwsYTRMF1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: aquantia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2018 10:32:27.7999 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 78a79145-0fc9-464f-6112-08d625f6de29 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 v3 17/22] 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: Sat, 29 Sep 2018 10:32:35 -0000 From: Pavel Belous Signed-off-by: Igor Russkikh Signed-off-by: Pavel Belous --- drivers/net/atlantic/atl_ethdev.c | 126 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 243020dc00a9..b71028d9d227 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -54,6 +54,8 @@ static void atl_dev_info_get(struct rte_eth_dev *dev, static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev); +static int atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); + /* Flow control */ static int atl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf); @@ -70,6 +72,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); + +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, @@ -211,6 +225,8 @@ static const struct eth_dev_ops atl_eth_dev_ops = { .dev_infos_get = atl_dev_info_get, .dev_supported_ptypes_get = atl_dev_supported_ptypes_get, + .mtu_set = atl_dev_mtu_set, + /* Queue Control */ .rx_queue_start = atl_rx_queue_start, .rx_queue_stop = atl_rx_queue_stop, @@ -234,6 +250,11 @@ static const struct eth_dev_ops atl_eth_dev_ops = { .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, .rxq_info_get = atl_rxq_info_get, .txq_info_get = atl_txq_info_get, @@ -1174,6 +1195,111 @@ 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_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct rte_eth_dev_info dev_info; + uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; + + atl_dev_info_get(dev, &dev_info); + + if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen)) + return -EINVAL; + + /* update max frame size */ + dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size; + + 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.7.4