From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0085.outbound.protection.outlook.com [104.47.32.85]) by dpdk.org (Postfix) with ESMTP id E4E8E1B46D for ; Tue, 9 Oct 2018 11:31:59 +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=JGo3ret/EkFghigYT2HkhtpYuHeRERyuyMG0OILKrO8=; b=ZtE9dF/w0iCY25R5VcbTA7QJl4UypV/5UJ2RQRio8MlEeJPnlMP272sF5QFUg7yGh4dRTq1gjFW0KFQt6c8ywCtX55HGmq703gr+WYSrOXS8KK1mUgkA7+1Ooikb3mUbHXm5aLRWZit69KbkUjAguDnCYnKhH//nHfiyirCYqg4= Received: from BLUPR0701MB1651.namprd07.prod.outlook.com (10.163.84.21) by BLUPR0701MB1650.namprd07.prod.outlook.com (10.163.84.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.23; Tue, 9 Oct 2018 09:31:58 +0000 Received: from BLUPR0701MB1651.namprd07.prod.outlook.com ([fe80::7c97:1527:4c0:8b46]) by BLUPR0701MB1651.namprd07.prod.outlook.com ([fe80::7c97:1527:4c0:8b46%3]) with mapi id 15.20.1207.024; Tue, 9 Oct 2018 09:31:58 +0000 From: Igor Russkikh To: "dev@dpdk.org" CC: Pavel Belous , Igor Russkikh , "ferruh.yigit@intel.com" , Pavel Belous Thread-Topic: [PATCH v4 17/22] net/atlantic: MAC address manipulations Thread-Index: AQHUX7LsDWBatMCuNEet6HJ/S2m18Q== Date: Tue, 9 Oct 2018 09:31:58 +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: AM0PR01CA0028.eurprd01.prod.exchangelabs.com (2603:10a6:208:69::41) To BLUPR0701MB1651.namprd07.prod.outlook.com (2a01:111:e400:58c6::21) 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; BLUPR0701MB1650; 6:z64KziV3ZcbCvC8pgAaCtSgc+9YxJhWNfKHriweZCpb4AmS7hYDF0OkmwOYLWkNWgpePMUYevhoIEnFItiqgJk/AEOqwmWIIljJm07jwxJQHfRmf4KvhlUfSOFbhFkVskQNZq8usszoeK23GQkDP8iP8pTsBP4mZFyFaXUD9A0ERPdbe7mlgLxMDieUvasWkfT+BVzsU14Bkg3N645GI8R2XNvv/7GiGzmhoqlPf5ruwF3w5g6tCOODTNaGD67joVsvUEOU68Zp1O26jHQoo2uPjE9MFvYKXTZlCpmVAZZUeSzoVQA1q8tsOeezejYeDMw0D+5EqXXOafs10jS5pEuu4+YPKUhjD2Pll5ByGsBi5PqiBjH9cFR5zkB3h99NfGLuZMC98Na/CRZWHVNQJMBLEN1LloGuC6ocygmYwjmoNCztIgR5c/aC0qJp/P8e3jbvsUO4cD5jhqPyQvfJoZw==; 5:KPWN6kpSV9QOKauHnW1PZiYa63fADV5Qo2IhN8f2NN5Yq5q+JtB9ZmndTnGQDG42qEM1T2vaZrU3TvDQ0+UtFBOrqIM2yuKBv/bfc0tERGSIBkffQnES3mTKb1h9i5M5DXJefUyMjmpX3+VWxgdgWdv3Oo7kVdkddZqy1lUq6/U=; 7:GjvxaPTPDYvHVojfpBtDlHDTqEUM5kG/yPTL0bPDCEizLBCy/7wodwwYF3Bugdrpuun9PFJW12Nro7+r0QRc+IWXJNv51bo/Da4giqVfXLvP/dkCqCOVmo9ILCZNg0+mgslCREy2I1QZK11ABlWQYy40lykYxh2fSVfnFDwgRXTrbC6TA2V8rp+qvHkznthpjM9OnfCvx7cWBQr7ckOgJEKg5+8bQRW+BNQ0IzLyQxtChSgI5Q4+urfPNEwXdrAq x-ms-office365-filtering-correlation-id: f586b1f3-b974-42a6-6119-08d62dca0f41 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BLUPR0701MB1650; x-ms-traffictypediagnostic: BLUPR0701MB1650: 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)(3231355)(944501410)(52105095)(93006095)(93001095)(3002001)(149066)(150057)(6041310)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(201708071742011)(7699051); SRVR:BLUPR0701MB1650; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB1650; x-forefront-prvs: 08200063E9 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39850400004)(346002)(376002)(396003)(136003)(189003)(199004)(81156014)(5640700003)(6116002)(71200400001)(105586002)(68736007)(316002)(3846002)(107886003)(71190400001)(26005)(118296001)(2616005)(5250100002)(25786009)(4326008)(102836004)(44832011)(446003)(476003)(11346002)(186003)(2906002)(106356001)(97736004)(2501003)(2351001)(486006)(478600001)(99286004)(53936002)(386003)(1730700003)(5660300001)(6506007)(36756003)(66066001)(54906003)(305945005)(256004)(14444005)(86362001)(575784001)(7736002)(2900100001)(76176011)(8936002)(52116002)(8676002)(6486002)(72206003)(6436002)(14454004)(81166006)(6512007)(6916009)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB1650; H:BLUPR0701MB1651.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: EDA1v+mHMbn5AbYPlML3Erfrm7uLPBj++YRpGgRriLR+Kuhi2vMomAlZUbb+lWyErr27yCRVTj281R/kB7YI7E8+LVIEjCpqtWNJHtHiA+sIn5BzgdqbSQzLjPdGoUZ/GCKbJVqA7kexGKsSShqk4opxZ8cYg1xcvO0Poj0dCu4lrGK7BIV3YK2Fs6gDXNXuusD05lAbU1HyyCje1oPmILYjo+x21sIelVNwkqm61LRagBIm2NWMhjHx4xsTCLBXBt4tgHcu6mNK11ZgTKG9TVCGaiXA59JkzZxH6PHRm0oabYb/XKEtNkrYEZ65kyUuZj/et8jAUCPGvBYEGuEAadSG91qqQkb1sSZTCRXa6iM= 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: f586b1f3-b974-42a6-6119-08d62dca0f41 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Oct 2018 09:31:58.6083 (UTC) 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 v4 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: Tue, 09 Oct 2018 09:32:00 -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_e= thdev.c index efdd83fb4d6b..3f0d2e26d7da 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, =20 static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *de= v); =20 +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); =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, @@ -214,6 +228,8 @@ static const struct eth_dev_ops atl_eth_dev_ops =3D { .dev_infos_get =3D atl_dev_info_get, .dev_supported_ptypes_get =3D atl_dev_supported_ptypes_get, =20 + .mtu_set =3D atl_dev_mtu_set, + /* Queue Control */ .rx_queue_start =3D atl_rx_queue_start, .rx_queue_stop =3D atl_rx_queue_stop, @@ -237,6 +253,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 @@ -1174,6 +1195,111 @@ atl_flow_ctrl_set(struct rte_eth_dev *dev, struct r= te_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_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct rte_eth_dev_info dev_info; + uint32_t frame_size =3D 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 =3D 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 =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