[v7,11/14] net/idpf: add support for MTU configuration
Checks
Commit Message
Add dev ops mtu_set.
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Signed-off-by: Junfeng Guo <junfeng.guo@intel.com>
---
doc/guides/nics/features/idpf.ini | 1 +
drivers/net/idpf/idpf_ethdev.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
@@ -10,6 +10,7 @@
Queue start/stop = Y
Runtime Rx queue setup = Y
Runtime Tx queue setup = Y
+MTU update = Y
TSO = P
L3 checksum offload = P
L4 checksum offload = P
@@ -32,6 +32,7 @@ static int idpf_dev_stop(struct rte_eth_dev *dev);
static int idpf_dev_close(struct rte_eth_dev *dev);
static int idpf_dev_info_get(struct rte_eth_dev *dev,
struct rte_eth_dev_info *dev_info);
+static int idpf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
static void idpf_adapter_rel(struct idpf_adapter *adapter);
int
@@ -70,6 +71,7 @@ static const struct eth_dev_ops idpf_eth_dev_ops = {
.tx_queue_release = idpf_dev_tx_queue_release,
.dev_infos_get = idpf_dev_info_get,
.link_update = idpf_dev_link_update,
+ .mtu_set = idpf_dev_mtu_set,
};
static int
@@ -83,6 +85,9 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
+ dev_info->max_mtu = dev_info->max_rx_pktlen - IDPF_ETH_OVERHEAD;
+ dev_info->min_mtu = RTE_ETHER_MIN_MTU;
+
dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
dev_info->max_mac_addrs = IDPF_NUM_MACADDR_MAX;
dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP |
@@ -131,6 +136,18 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
return 0;
}
+static int
+idpf_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) {
+ PMD_DRV_LOG(ERR, "port must be stopped before configuration");
+ return -EBUSY;
+ }
+
+ return 0;
+}
+
static int
idpf_init_vport_req_info(struct rte_eth_dev *dev)
{
@@ -429,6 +446,13 @@ idpf_dev_start(struct rte_eth_dev *dev)
vport->stopped = 0;
+ if (dev->data->mtu > vport->max_mtu) {
+ PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+ goto err_mtu;
+ }
+
+ vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
+
if (idpf_start_queues(dev)) {
PMD_DRV_LOG(ERR, "Failed to start queues");
goto err_mtu;