From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00044.outbound.protection.outlook.com [40.107.0.44]) by dpdk.org (Postfix) with ESMTP id D7B7E4D3A for ; Mon, 8 Apr 2019 13:22:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZGIK045+WVM4l7OyAkisxiexILW5QxNVeFDP0J8waf8=; b=PTUly9lgVnRvPgHq+nuYWyLoGW1J0KxgZk2Y6ZUMKdcoFxYzvpyNtilszrVnRf0oYV0Z8o50GdLAr2ftH+39JY64KkZM4P/N40uQ0+6mdyKD3nlHOzR0fxccyaksgWASApJiErageJkfVgslQ3GDnoSnpzvQwpatdIUNGdPSVZU= Received: from VE1PR04MB6365.eurprd04.prod.outlook.com (10.255.118.78) by VE1PR04MB6606.eurprd04.prod.outlook.com (20.179.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.13; Mon, 8 Apr 2019 11:22:42 +0000 Received: from VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0]) by VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0%3]) with mapi id 15.20.1771.016; Mon, 8 Apr 2019 11:22:42 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , "ferruh.yigit@intel.com" CC: Gagandeep Singh Thread-Topic: [PATCH 09/13] net/enetc: add MTU update and jumbo frames support Thread-Index: AQHU7f1hAK/P3tg84U6jjxBMN0gpSQ== Date: Mon, 8 Apr 2019 11:22:42 +0000 Message-ID: <1554745507-15089-10-git-send-email-g.singh@nxp.com> References: <1554745507-15089-1-git-send-email-g.singh@nxp.com> In-Reply-To: <1554745507-15089-1-git-send-email-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0003.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::13) To VE1PR04MB6365.eurprd04.prod.outlook.com (2603:10a6:803:12a::14) x-mailer: git-send-email 1.9.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [92.120.1.67] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7abe5eac-06af-4bb6-0be2-08d6bc14841a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VE1PR04MB6606; x-ms-traffictypediagnostic: VE1PR04MB6606: x-microsoft-antispam-prvs: x-forefront-prvs: 0001227049 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(346002)(39860400002)(396003)(136003)(199004)(189003)(76176011)(97736004)(81156014)(71200400001)(71190400001)(15650500001)(72206003)(3846002)(25786009)(81166006)(53936002)(2616005)(5660300002)(6116002)(8676002)(7736002)(446003)(478600001)(8936002)(11346002)(305945005)(2906002)(256004)(14444005)(66066001)(6512007)(476003)(6436002)(486006)(50226002)(2501003)(99286004)(106356001)(86362001)(110136005)(4326008)(6486002)(68736007)(105586002)(6506007)(52116002)(316002)(26005)(386003)(14454004)(186003)(36756003)(102836004); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6606; H:VE1PR04MB6365.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: POoKhsPXLM0XhVQSd2pJVHr/mKYkikGJvwgW22zmDOcKXoQoMbgWrtmKRTQV/TYXR1ENxKaAS/zAnQVxsNKm0ugOYd3qr9prqF5rEmJ5ZPdPuJVctq2RP/fYMjw1b8hG0JfB0YRZXrTtJRGybAQwpCR1SbuNRH2jkrDAKdDFzye6AopBYr68tfO0LXuP4xLmETwchx+48yE7d+1MiCHYmQdX/Hur6GBDUBavLdQHZHeu09sV2Iph8BxccsESJnqKILW6lQ1P7hp2BJavib1ANEkequ+e9XmdIOBKIH2kaVD3iDfXdlZMBLg+Zb66RZeyWXerTA34dYLN99itd+sQSjIoLIBls8r8PpQ4MxODBYU2iPhVnhuSJwUd5h3jtyb1wsqXYDswyKZWTngQVep2JrzO7vW3Wp4rn7ndgPfziy4= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7abe5eac-06af-4bb6-0be2-08d6bc14841a X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2019 11:22:42.6234 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6606 Subject: [dpdk-dev] [PATCH 09/13] net/enetc: add MTU update and jumbo frames support 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: Mon, 08 Apr 2019 11:22:44 -0000 Enable the jumbo frames and mtu update feature. Signed-off-by: Gagandeep Singh --- doc/guides/nics/enetc.rst | 1 + doc/guides/nics/features/enetc.ini | 2 + drivers/net/enetc/base/enetc_hw.h | 6 ++- drivers/net/enetc/enetc.h | 5 +++ drivers/net/enetc/enetc_ethdev.c | 86 ++++++++++++++++++++++++++++++++++= ---- 5 files changed, 91 insertions(+), 9 deletions(-) diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst index ab13211..eeb0752 100644 --- a/doc/guides/nics/enetc.rst +++ b/doc/guides/nics/enetc.rst @@ -49,6 +49,7 @@ ENETC Features - Basic stats - Promiscuous - Multicast +- Jumbo packets =20 NIC Driver (PMD) ~~~~~~~~~~~~~~~~ diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/= enetc.ini index 6b7bbfb..0eed2cb 100644 --- a/doc/guides/nics/features/enetc.ini +++ b/doc/guides/nics/features/enetc.ini @@ -9,6 +9,8 @@ Link status =3D Y Basic stats =3D Y Promiscuous mode =3D Y Allmulticast mode =3D Y +MTU update =3D Y +Jumbo frame =3D Y Linux VFIO =3D Y ARMv8 =3D Y Usage doc =3D Y diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/ene= tc_hw.h index 90a383a..2eb1df3 100644 --- a/drivers/net/enetc/base/enetc_hw.h +++ b/drivers/net/enetc/base/enetc_hw.h @@ -99,7 +99,11 @@ #define ENETC_PM0_RX_EN BIT(1) =20 #define ENETC_PM0_MAXFRM 0x08014 -#define ENETC_SET_MAXFRM(val) ((val) << 16) +#define ENETC_SET_TX_MTU(val) ((val) << 16) +#define ENETC_SET_MAXFRM(val) ((val) & 0xffff) +#define ENETC_PTXMBAR 0x0608 +/* n =3D TC index [0..7] */ +#define ENETC_PTCMSDUR(n) (0x2020 + (n) * 4) =20 #define ENETC_PM0_STATUS 0x08304 #define ENETC_LINK_MODE 0x0000000000080000ULL diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h index 56454dc..e494eb8 100644 --- a/drivers/net/enetc/enetc.h +++ b/drivers/net/enetc/enetc.h @@ -24,6 +24,11 @@ /* BD ALIGN */ #define BD_ALIGN 8 =20 +/* minimum frame size supported */ +#define ENETC_MAC_MINFRM_SIZE 68 +/* maximum frame size supported */ +#define ENETC_MAC_MAXFRM_SIZE 9600 + /* * upper_32_bits - return bits 32-63 of a number * @n: the number we're accessing diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_eth= dev.c index 0bb3b2c..4428678 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -11,13 +11,6 @@ int enetc_logtype_pmd; =20 static int -enetc_dev_configure(struct rte_eth_dev *dev __rte_unused) -{ - PMD_INIT_FUNC_TRACE(); - return 0; -} - -static int enetc_dev_start(struct rte_eth_dev *dev) { struct enetc_eth_hw *hw =3D @@ -168,7 +161,8 @@ }; dev_info->max_rx_queues =3D MAX_RX_RINGS; dev_info->max_tx_queues =3D MAX_TX_RINGS; - dev_info->max_rx_pktlen =3D 1500; + dev_info->max_rx_pktlen =3D ENETC_MAC_MAXFRM_SIZE; + dev_info->rx_offload_capa =3D DEV_RX_OFFLOAD_JUMBO_FRAME; } =20 static int @@ -602,6 +596,76 @@ int enetc_stats_get(struct rte_eth_dev *dev, enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr); } =20 +static int +enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct enetc_eth_hw *hw =3D + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw =3D &hw->hw; + uint32_t frame_size =3D mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; + + /* check that mtu is within the allowed range */ + if (mtu < ENETC_MAC_MINFRM_SIZE || frame_size > ENETC_MAC_MAXFRM_SIZE) + return -EINVAL; + + /* + * Refuse mtu that requires the support of scattered packets + * when this feature has not been enabled before. + */ + if (dev->data->min_rx_buf_size && + !dev->data->scattered_rx && frame_size > + dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) { + ENETC_PMD_ERR("SG not enabled, will not fit in one buffer"); + return -EINVAL; + } + + if (frame_size > ETHER_MAX_LEN) + dev->data->dev_conf.rxmode.offloads &=3D + DEV_RX_OFFLOAD_JUMBO_FRAME; + else + dev->data->dev_conf.rxmode.offloads &=3D + ~DEV_RX_OFFLOAD_JUMBO_FRAME; + + enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), ENETC_MAC_MAXFRM_SIZE); + enetc_port_wr(enetc_hw, ENETC_PTXMBAR, 2 * ENETC_MAC_MAXFRM_SIZE); + + dev->data->dev_conf.rxmode.max_rx_pkt_len =3D frame_size; + + /*setting the MTU*/ + enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM, ENETC_SET_MAXFRM(frame_size) | + ENETC_SET_TX_MTU(ENETC_MAC_MAXFRM_SIZE)); + + return 0; +} + +static int +enetc_dev_configure(struct rte_eth_dev *dev) +{ + struct rte_eth_conf *eth_conf =3D &dev->data->dev_conf; + uint64_t rx_offloads =3D eth_conf->rxmode.offloads; + struct enetc_eth_hw *hw =3D + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw =3D &hw->hw; + + PMD_INIT_FUNC_TRACE(); + + if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) { + uint32_t max_len; + + max_len =3D dev->data->dev_conf.rxmode.max_rx_pkt_len; + + enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM, + ENETC_SET_MAXFRM(max_len)); + enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), + ENETC_MAC_MAXFRM_SIZE); + enetc_port_wr(enetc_hw, ENETC_PTXMBAR, + 2 * ENETC_MAC_MAXFRM_SIZE); + dev->data->mtu =3D ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN; + } + + return 0; +} + /* * The set of PCI devices this driver supports */ @@ -625,6 +689,7 @@ int enetc_stats_get(struct rte_eth_dev *dev, .allmulticast_enable =3D enetc_allmulticast_enable, .allmulticast_disable =3D enetc_allmulticast_disable, .dev_infos_get =3D enetc_dev_infos_get, + .mtu_set =3D enetc_mtu_set, .rx_queue_setup =3D enetc_rx_queue_setup, .rx_queue_release =3D enetc_rx_queue_release, .tx_queue_setup =3D enetc_tx_queue_setup, @@ -679,6 +744,11 @@ int enetc_stats_get(struct rte_eth_dev *dev, ether_addr_copy((struct ether_addr *)hw->mac.addr, ð_dev->data->mac_addrs[0]); =20 + /* Set MTU */ + enetc_port_wr(&hw->hw, ENETC_PM0_MAXFRM, + ENETC_SET_MAXFRM(ETHER_MAX_LEN)); + eth_dev->data->mtu =3D ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN; + ENETC_PMD_DEBUG("port_id %d vendorID=3D0x%x deviceID=3D0x%x", eth_dev->data->port_id, pci_dev->id.vendor_id, pci_dev->id.device_id); --=20 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 62B5EA0096 for ; Mon, 8 Apr 2019 13:23:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7F2AE5B36; Mon, 8 Apr 2019 13:23:05 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00044.outbound.protection.outlook.com [40.107.0.44]) by dpdk.org (Postfix) with ESMTP id D7B7E4D3A for ; Mon, 8 Apr 2019 13:22:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZGIK045+WVM4l7OyAkisxiexILW5QxNVeFDP0J8waf8=; b=PTUly9lgVnRvPgHq+nuYWyLoGW1J0KxgZk2Y6ZUMKdcoFxYzvpyNtilszrVnRf0oYV0Z8o50GdLAr2ftH+39JY64KkZM4P/N40uQ0+6mdyKD3nlHOzR0fxccyaksgWASApJiErageJkfVgslQ3GDnoSnpzvQwpatdIUNGdPSVZU= Received: from VE1PR04MB6365.eurprd04.prod.outlook.com (10.255.118.78) by VE1PR04MB6606.eurprd04.prod.outlook.com (20.179.235.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.13; Mon, 8 Apr 2019 11:22:42 +0000 Received: from VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0]) by VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0%3]) with mapi id 15.20.1771.016; Mon, 8 Apr 2019 11:22:42 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , "ferruh.yigit@intel.com" CC: Gagandeep Singh Thread-Topic: [PATCH 09/13] net/enetc: add MTU update and jumbo frames support Thread-Index: AQHU7f1hAK/P3tg84U6jjxBMN0gpSQ== Date: Mon, 8 Apr 2019 11:22:42 +0000 Message-ID: <1554745507-15089-10-git-send-email-g.singh@nxp.com> References: <1554745507-15089-1-git-send-email-g.singh@nxp.com> In-Reply-To: <1554745507-15089-1-git-send-email-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0003.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::13) To VE1PR04MB6365.eurprd04.prod.outlook.com (2603:10a6:803:12a::14) x-mailer: git-send-email 1.9.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [92.120.1.67] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7abe5eac-06af-4bb6-0be2-08d6bc14841a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VE1PR04MB6606; x-ms-traffictypediagnostic: VE1PR04MB6606: x-microsoft-antispam-prvs: x-forefront-prvs: 0001227049 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(346002)(39860400002)(396003)(136003)(199004)(189003)(76176011)(97736004)(81156014)(71200400001)(71190400001)(15650500001)(72206003)(3846002)(25786009)(81166006)(53936002)(2616005)(5660300002)(6116002)(8676002)(7736002)(446003)(478600001)(8936002)(11346002)(305945005)(2906002)(256004)(14444005)(66066001)(6512007)(476003)(6436002)(486006)(50226002)(2501003)(99286004)(106356001)(86362001)(110136005)(4326008)(6486002)(68736007)(105586002)(6506007)(52116002)(316002)(26005)(386003)(14454004)(186003)(36756003)(102836004); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6606; H:VE1PR04MB6365.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: POoKhsPXLM0XhVQSd2pJVHr/mKYkikGJvwgW22zmDOcKXoQoMbgWrtmKRTQV/TYXR1ENxKaAS/zAnQVxsNKm0ugOYd3qr9prqF5rEmJ5ZPdPuJVctq2RP/fYMjw1b8hG0JfB0YRZXrTtJRGybAQwpCR1SbuNRH2jkrDAKdDFzye6AopBYr68tfO0LXuP4xLmETwchx+48yE7d+1MiCHYmQdX/Hur6GBDUBavLdQHZHeu09sV2Iph8BxccsESJnqKILW6lQ1P7hp2BJavib1ANEkequ+e9XmdIOBKIH2kaVD3iDfXdlZMBLg+Zb66RZeyWXerTA34dYLN99itd+sQSjIoLIBls8r8PpQ4MxODBYU2iPhVnhuSJwUd5h3jtyb1wsqXYDswyKZWTngQVep2JrzO7vW3Wp4rn7ndgPfziy4= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7abe5eac-06af-4bb6-0be2-08d6bc14841a X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2019 11:22:42.6234 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6606 Subject: [dpdk-dev] [PATCH 09/13] net/enetc: add MTU update and jumbo frames support 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190408112242.clTlTpTxYQSf3L9VaRDNDkGXdbZ3ylvGtLYShdQ5ghA@z> Enable the jumbo frames and mtu update feature. Signed-off-by: Gagandeep Singh --- doc/guides/nics/enetc.rst | 1 + doc/guides/nics/features/enetc.ini | 2 + drivers/net/enetc/base/enetc_hw.h | 6 ++- drivers/net/enetc/enetc.h | 5 +++ drivers/net/enetc/enetc_ethdev.c | 86 ++++++++++++++++++++++++++++++++++= ---- 5 files changed, 91 insertions(+), 9 deletions(-) diff --git a/doc/guides/nics/enetc.rst b/doc/guides/nics/enetc.rst index ab13211..eeb0752 100644 --- a/doc/guides/nics/enetc.rst +++ b/doc/guides/nics/enetc.rst @@ -49,6 +49,7 @@ ENETC Features - Basic stats - Promiscuous - Multicast +- Jumbo packets =20 NIC Driver (PMD) ~~~~~~~~~~~~~~~~ diff --git a/doc/guides/nics/features/enetc.ini b/doc/guides/nics/features/= enetc.ini index 6b7bbfb..0eed2cb 100644 --- a/doc/guides/nics/features/enetc.ini +++ b/doc/guides/nics/features/enetc.ini @@ -9,6 +9,8 @@ Link status =3D Y Basic stats =3D Y Promiscuous mode =3D Y Allmulticast mode =3D Y +MTU update =3D Y +Jumbo frame =3D Y Linux VFIO =3D Y ARMv8 =3D Y Usage doc =3D Y diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/ene= tc_hw.h index 90a383a..2eb1df3 100644 --- a/drivers/net/enetc/base/enetc_hw.h +++ b/drivers/net/enetc/base/enetc_hw.h @@ -99,7 +99,11 @@ #define ENETC_PM0_RX_EN BIT(1) =20 #define ENETC_PM0_MAXFRM 0x08014 -#define ENETC_SET_MAXFRM(val) ((val) << 16) +#define ENETC_SET_TX_MTU(val) ((val) << 16) +#define ENETC_SET_MAXFRM(val) ((val) & 0xffff) +#define ENETC_PTXMBAR 0x0608 +/* n =3D TC index [0..7] */ +#define ENETC_PTCMSDUR(n) (0x2020 + (n) * 4) =20 #define ENETC_PM0_STATUS 0x08304 #define ENETC_LINK_MODE 0x0000000000080000ULL diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h index 56454dc..e494eb8 100644 --- a/drivers/net/enetc/enetc.h +++ b/drivers/net/enetc/enetc.h @@ -24,6 +24,11 @@ /* BD ALIGN */ #define BD_ALIGN 8 =20 +/* minimum frame size supported */ +#define ENETC_MAC_MINFRM_SIZE 68 +/* maximum frame size supported */ +#define ENETC_MAC_MAXFRM_SIZE 9600 + /* * upper_32_bits - return bits 32-63 of a number * @n: the number we're accessing diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_eth= dev.c index 0bb3b2c..4428678 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -11,13 +11,6 @@ int enetc_logtype_pmd; =20 static int -enetc_dev_configure(struct rte_eth_dev *dev __rte_unused) -{ - PMD_INIT_FUNC_TRACE(); - return 0; -} - -static int enetc_dev_start(struct rte_eth_dev *dev) { struct enetc_eth_hw *hw =3D @@ -168,7 +161,8 @@ }; dev_info->max_rx_queues =3D MAX_RX_RINGS; dev_info->max_tx_queues =3D MAX_TX_RINGS; - dev_info->max_rx_pktlen =3D 1500; + dev_info->max_rx_pktlen =3D ENETC_MAC_MAXFRM_SIZE; + dev_info->rx_offload_capa =3D DEV_RX_OFFLOAD_JUMBO_FRAME; } =20 static int @@ -602,6 +596,76 @@ int enetc_stats_get(struct rte_eth_dev *dev, enetc_port_wr(enetc_hw, ENETC_PSIPMR, psipmr); } =20 +static int +enetc_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct enetc_eth_hw *hw =3D + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw =3D &hw->hw; + uint32_t frame_size =3D mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; + + /* check that mtu is within the allowed range */ + if (mtu < ENETC_MAC_MINFRM_SIZE || frame_size > ENETC_MAC_MAXFRM_SIZE) + return -EINVAL; + + /* + * Refuse mtu that requires the support of scattered packets + * when this feature has not been enabled before. + */ + if (dev->data->min_rx_buf_size && + !dev->data->scattered_rx && frame_size > + dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) { + ENETC_PMD_ERR("SG not enabled, will not fit in one buffer"); + return -EINVAL; + } + + if (frame_size > ETHER_MAX_LEN) + dev->data->dev_conf.rxmode.offloads &=3D + DEV_RX_OFFLOAD_JUMBO_FRAME; + else + dev->data->dev_conf.rxmode.offloads &=3D + ~DEV_RX_OFFLOAD_JUMBO_FRAME; + + enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), ENETC_MAC_MAXFRM_SIZE); + enetc_port_wr(enetc_hw, ENETC_PTXMBAR, 2 * ENETC_MAC_MAXFRM_SIZE); + + dev->data->dev_conf.rxmode.max_rx_pkt_len =3D frame_size; + + /*setting the MTU*/ + enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM, ENETC_SET_MAXFRM(frame_size) | + ENETC_SET_TX_MTU(ENETC_MAC_MAXFRM_SIZE)); + + return 0; +} + +static int +enetc_dev_configure(struct rte_eth_dev *dev) +{ + struct rte_eth_conf *eth_conf =3D &dev->data->dev_conf; + uint64_t rx_offloads =3D eth_conf->rxmode.offloads; + struct enetc_eth_hw *hw =3D + ENETC_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct enetc_hw *enetc_hw =3D &hw->hw; + + PMD_INIT_FUNC_TRACE(); + + if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) { + uint32_t max_len; + + max_len =3D dev->data->dev_conf.rxmode.max_rx_pkt_len; + + enetc_port_wr(enetc_hw, ENETC_PM0_MAXFRM, + ENETC_SET_MAXFRM(max_len)); + enetc_port_wr(enetc_hw, ENETC_PTCMSDUR(0), + ENETC_MAC_MAXFRM_SIZE); + enetc_port_wr(enetc_hw, ENETC_PTXMBAR, + 2 * ENETC_MAC_MAXFRM_SIZE); + dev->data->mtu =3D ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN; + } + + return 0; +} + /* * The set of PCI devices this driver supports */ @@ -625,6 +689,7 @@ int enetc_stats_get(struct rte_eth_dev *dev, .allmulticast_enable =3D enetc_allmulticast_enable, .allmulticast_disable =3D enetc_allmulticast_disable, .dev_infos_get =3D enetc_dev_infos_get, + .mtu_set =3D enetc_mtu_set, .rx_queue_setup =3D enetc_rx_queue_setup, .rx_queue_release =3D enetc_rx_queue_release, .tx_queue_setup =3D enetc_tx_queue_setup, @@ -679,6 +744,11 @@ int enetc_stats_get(struct rte_eth_dev *dev, ether_addr_copy((struct ether_addr *)hw->mac.addr, ð_dev->data->mac_addrs[0]); =20 + /* Set MTU */ + enetc_port_wr(&hw->hw, ENETC_PM0_MAXFRM, + ENETC_SET_MAXFRM(ETHER_MAX_LEN)); + eth_dev->data->mtu =3D ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN; + ENETC_PMD_DEBUG("port_id %d vendorID=3D0x%x deviceID=3D0x%x", eth_dev->data->port_id, pci_dev->id.vendor_id, pci_dev->id.device_id); --=20 1.9.1