[v4,04/23] net/ice: add ops MTU-SET to dcf

Message ID 20220419154614.476154-5-kevinx.liu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series complete common VF features for DCF |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Kevin Liu April 19, 2022, 3:45 p.m. UTC
  From: Jie Wang <jie1x.wang@intel.com>

add API "mtu_set" to dcf, and it can configure the port mtu through
cmdline.

Signed-off-by: Jie Wang <jie1x.wang@intel.com>
Signed-off-by: Kevin Liu <kevinx.liu@intel.com>
---
 drivers/net/ice/ice_dcf_ethdev.c | 14 ++++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h |  6 ++++++
 2 files changed, 20 insertions(+)
  

Patch

diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c
index d8b5961514..06d752fd61 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -1081,6 +1081,19 @@  ice_dcf_link_update(struct rte_eth_dev *dev,
 	return rte_eth_linkstatus_set(dev, &new_link);
 }
 
+static int
+ice_dcf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu __rte_unused)
+{
+	/* mtu setting is forbidden if port is start */
+	if (dev->data->dev_started != 0) {
+		PMD_DRV_LOG(ERR, "port %d must be stopped before configuration",
+			    dev->data->port_id);
+		return -EBUSY;
+	}
+
+	return 0;
+}
+
 bool
 ice_dcf_adminq_need_retry(struct ice_adapter *ad)
 {
@@ -1236,6 +1249,7 @@  static const struct eth_dev_ops ice_dcf_eth_dev_ops = {
 	.rss_hash_update         = ice_dcf_dev_rss_hash_update,
 	.rss_hash_conf_get       = ice_dcf_dev_rss_hash_conf_get,
 	.tx_done_cleanup         = ice_tx_done_cleanup,
+	.mtu_set                 = ice_dcf_dev_mtu_set,
 };
 
 static int
diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h
index 11a1305038..f2faf26f58 100644
--- a/drivers/net/ice/ice_dcf_ethdev.h
+++ b/drivers/net/ice/ice_dcf_ethdev.h
@@ -15,6 +15,12 @@ 
 
 #define ICE_DCF_MAX_RINGS  1
 
+#define ICE_DCF_FRAME_SIZE_MAX       9728
+#define ICE_DCF_VLAN_TAG_SIZE               4
+#define ICE_DCF_ETH_OVERHEAD \
+	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + ICE_DCF_VLAN_TAG_SIZE * 2)
+#define ICE_DCF_ETH_MAX_LEN (RTE_ETHER_MTU + ICE_DCF_ETH_OVERHEAD)
+
 struct ice_dcf_queue {
 	uint64_t dummy;
 };