net/i40e: enable VF MTU change
authorQi Zhang <qi.z.zhang@intel.com>
Tue, 17 Jan 2017 08:45:10 +0000 (16:45 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:41:43 +0000 (19:41 +0100)
This patch implement mtu_set ops for i40e VF.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>
Acked-by: Vincent Jardin <vincent.jardin@6wind.com>
drivers/net/i40e/i40e_ethdev_vf.c

index f50ac2d..b292d1d 100644 (file)
@@ -151,6 +151,7 @@ static int i40evf_dev_rss_hash_update(struct rte_eth_dev *dev,
                                      struct rte_eth_rss_conf *rss_conf);
 static int i40evf_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
                                        struct rte_eth_rss_conf *rss_conf);
+static int i40evf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 static int
 i40evf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id);
 static int
@@ -225,6 +226,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
        .reta_query           = i40evf_dev_rss_reta_query,
        .rss_hash_update      = i40evf_dev_rss_hash_update,
        .rss_hash_conf_get    = i40evf_dev_rss_hash_conf_get,
+       .mtu_set              = i40evf_dev_mtu_set,
 };
 
 /*
@@ -2653,3 +2655,34 @@ i40evf_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 
        return 0;
 }
+
+static int
+i40evf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+       struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+       struct rte_eth_dev_data *dev_data = vf->dev_data;
+       uint32_t frame_size = mtu + ETHER_HDR_LEN
+                             + ETHER_CRC_LEN + I40E_VLAN_TAG_SIZE;
+       int ret = 0;
+
+       /* check if mtu is within the allowed range */
+       if ((mtu < ETHER_MIN_MTU) || (frame_size > I40E_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\n",
+                           dev_data->port_id);
+               return -EBUSY;
+       }
+
+       if (frame_size > ETHER_MAX_LEN)
+               dev_data->dev_conf.rxmode.jumbo_frame = 1;
+       else
+               dev_data->dev_conf.rxmode.jumbo_frame = 0;
+
+       dev_data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+
+       return ret;
+}