[v2,07/20] net/ice: support MTU setting

Message ID 1543820821-108122-8-git-send-email-wenzhuo.lu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series A new net PMD - ice |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Wenzhuo Lu Dec. 3, 2018, 7:06 a.m. UTC
  Add ops link_update.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
  

Comments

Varghese, Vipin Dec. 4, 2018, 5:25 a.m. UTC | #1
snipped
> +static int
> +ice_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
> +	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
> +	struct rte_eth_dev_data *dev_data = pf->dev_data;
> +	uint32_t frame_size = mtu + ETHER_HDR_LEN
> +			      + ETHER_CRC_LEN + ICE_VLAN_TAG_SIZE;

Should this be ' ICE_VLAN_TAG_SIZE' or ' ICE_SWITCH_VLAN_TAG_SIZE'?
snipped
  
Varghese, Vipin Dec. 4, 2018, 5:51 a.m. UTC | #2
Can you point me to the patch where 'get_mtu' is defined?

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Varghese, Vipin
> Sent: Tuesday, December 4, 2018 10:56 AM
> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Li, Xiaoyun <xiaoyun.li@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v2 07/20] net/ice: support MTU setting
> 
> snipped
> > +static int
> > +ice_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
> > +	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
> > +	struct rte_eth_dev_data *dev_data = pf->dev_data;
> > +	uint32_t frame_size = mtu + ETHER_HDR_LEN
> > +			      + ETHER_CRC_LEN + ICE_VLAN_TAG_SIZE;
> 
> Should this be ' ICE_VLAN_TAG_SIZE' or ' ICE_SWITCH_VLAN_TAG_SIZE'?
> snipped
  
Wenzhuo Lu Dec. 6, 2018, 5:35 a.m. UTC | #3
Hi Vipin,


> -----Original Message-----
> From: Varghese, Vipin
> Sent: Tuesday, December 4, 2018 1:26 PM
> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Li, Xiaoyun <xiaoyun.li@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v2 07/20] net/ice: support MTU setting
> 
> snipped
> > +static int
> > +ice_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) {
> > +	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data-
> >dev_private);
> > +	struct rte_eth_dev_data *dev_data = pf->dev_data;
> > +	uint32_t frame_size = mtu + ETHER_HDR_LEN
> > +			      + ETHER_CRC_LEN + ICE_VLAN_TAG_SIZE;
> 
> Should this be ' ICE_VLAN_TAG_SIZE' or ' ICE_SWITCH_VLAN_TAG_SIZE'?
Don't get it. What should be changed?

> snipped
  
Wenzhuo Lu Dec. 6, 2018, 5:41 a.m. UTC | #4
Hi Vipin,

> -----Original Message-----
> From: Varghese, Vipin
> Sent: Tuesday, December 4, 2018 1:52 PM
> To: Varghese, Vipin <vipin.varghese@intel.com>; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Li, Xiaoyun <xiaoyun.li@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v2 07/20] net/ice: support MTU setting
> 
> Can you point me to the patch where 'get_mtu' is defined?
There's no 'get_mtu'. No such ops.
  
Varghese, Vipin Dec. 6, 2018, 5:56 a.m. UTC | #5
Thanks, I get what you are saying since by default ' rte_eth_dev_get_mtu' fetches MTU ' dev->data->mtu'. But is not ICE_DSI a switch so MTU would be picked up from switch HW ?

> -----Original Message-----
> From: Lu, Wenzhuo
> Sent: Thursday, December 6, 2018 11:11 AM
> To: Varghese, Vipin <vipin.varghese@intel.com>; dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Li, Xiaoyun <xiaoyun.li@intel.com>;
> Wu, Jingjing <jingjing.wu@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v2 07/20] net/ice: support MTU setting
> 
> Hi Vipin,
> 
> > -----Original Message-----
> > From: Varghese, Vipin
> > Sent: Tuesday, December 4, 2018 1:52 PM
> > To: Varghese, Vipin <vipin.varghese@intel.com>; Lu, Wenzhuo
> > <wenzhuo.lu@intel.com>; dev@dpdk.org
> > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> > <qiming.yang@intel.com>; Li, Xiaoyun <xiaoyun.li@intel.com>; Wu,
> > Jingjing <jingjing.wu@intel.com>
> > Subject: RE: [dpdk-dev] [PATCH v2 07/20] net/ice: support MTU setting
> >
> > Can you point me to the patch where 'get_mtu' is defined?
> There's no 'get_mtu'. No such ops.
  

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 164dfd5..bf290ab 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -23,6 +23,7 @@  static void ice_dev_info_get(struct rte_eth_dev *dev,
 			     struct rte_eth_dev_info *dev_info);
 static int ice_link_update(struct rte_eth_dev *dev,
 			   int wait_to_complete);
+static int ice_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 static const struct rte_pci_id pci_id_ice_map[] = {
 	{ RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E810C_BACKPLANE) },
@@ -48,6 +49,7 @@  static int ice_link_update(struct rte_eth_dev *dev,
 	.dev_infos_get                = ice_dev_info_get,
 	.dev_supported_ptypes_get     = ice_dev_supported_ptypes_get,
 	.link_update                  = ice_link_update,
+	.mtu_set                      = ice_mtu_set,
 };
 
 static void
@@ -1302,3 +1304,37 @@  static int ice_init_rss(struct ice_pf *pf)
 
 	return 0;
 }
+
+static int
+ice_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct rte_eth_dev_data *dev_data = pf->dev_data;
+	uint32_t frame_size = mtu + ETHER_HDR_LEN
+			      + ETHER_CRC_LEN + ICE_VLAN_TAG_SIZE;
+
+	ICE_PROC_SECONDARY_CHECK;
+
+	/* check if mtu is within the allowed range */
+	if (mtu < ETHER_MIN_MTU || frame_size > ICE_FRAME_SIZE_MAX)
+		return -EINVAL;
+
+	/* mtu setting is forbidden if port is start */
+	if (dev_data->dev_started) {
+		PMD_DRV_LOG(ERR,
+			    "port %d must be stopped before configuration",
+			    dev_data->port_id);
+		return -EBUSY;
+	}
+
+	if (frame_size > ETHER_MAX_LEN)
+		dev_data->dev_conf.rxmode.offloads |=
+			DEV_RX_OFFLOAD_JUMBO_FRAME;
+	else
+		dev_data->dev_conf.rxmode.offloads &=
+			~DEV_RX_OFFLOAD_JUMBO_FRAME;
+
+	dev_data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+	return 0;
+}