diff mbox series

[v3,21/34] net/ice: support MTU setting

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

Checks

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

Commit Message

Wenzhuo Lu Dec. 12, 2018, 6:59 a.m. UTC
Add ops mtu_set.

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 | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

Comments

Ferruh Yigit Dec. 13, 2018, 9:05 p.m. UTC | #1
On 12/12/2018 6:59 AM, Wenzhuo Lu wrote:
> Add ops mtu_set.
> 
> 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 | 34 ++++++++++++++++++++++++++++++++++

Can you please update the ice.ini file in the same patch feature added, it both
helps to verify the claimed features and provides extra documentation to patch,
same for all patches adding a feature.

Thanks,
ferruh
Wenzhuo Lu Dec. 14, 2018, 2:33 a.m. UTC | #2
Hi Ferruh,


> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Friday, December 14, 2018 5:06 AM
> To: Lu, Wenzhuo <wenzhuo.lu@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 v3 21/34] net/ice: support MTU setting
> 
> On 12/12/2018 6:59 AM, Wenzhuo Lu wrote:
> > Add ops mtu_set.
> >
> > 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 | 34
> ++++++++++++++++++++++++++++++++++
> 
> Can you please update the ice.ini file in the same patch feature added, it
> both helps to verify the claimed features and provides extra documentation
> to patch, same for all patches adding a feature.
Will change it in v4.

> 
> Thanks,
> ferruh
diff mbox series

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 518ce70..38e822f 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
@@ -1289,3 +1291,35 @@  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;
+
+	/* 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;
+}