From 4c4340ff301d3e0d50c49db2da47f9eb11a9eb75 Mon Sep 17 00:00:00 2001 From: Pavel Belous Date: Fri, 12 Oct 2018 11:09:45 +0000 Subject: [PATCH] net/atlantic: implement MTU configuration Add support for updating MTU value. Signed-off-by: Igor Russkikh Signed-off-by: Pavel Belous --- doc/guides/nics/features/atlantic.ini | 1 + drivers/net/atlantic/atl_ethdev.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/doc/guides/nics/features/atlantic.ini b/doc/guides/nics/features/atlantic.ini index 1dd3ff87e5..dd44ed75ae 100644 --- a/doc/guides/nics/features/atlantic.ini +++ b/doc/guides/nics/features/atlantic.ini @@ -8,6 +8,7 @@ Speed capabilities = Y Link status = Y Link status event = Y Queue start/stop = Y +MTU update = Y Jumbo frame = Y Promiscuous mode = Y Allmulticast mode = Y diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 6cee14b2dc..db2d798f28 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -48,6 +48,8 @@ static void atl_dev_info_get(struct rte_eth_dev *dev, static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev); +static int atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); + /* Flow control */ static int atl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf); @@ -219,6 +221,8 @@ static const struct eth_dev_ops atl_eth_dev_ops = { .dev_infos_get = atl_dev_info_get, .dev_supported_ptypes_get = atl_dev_supported_ptypes_get, + .mtu_set = atl_dev_mtu_set, + /* Queue Control */ .rx_queue_start = atl_rx_queue_start, .rx_queue_stop = atl_rx_queue_stop, @@ -1150,6 +1154,23 @@ atl_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr) return 0; } +static int +atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct rte_eth_dev_info dev_info; + uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; + + atl_dev_info_get(dev, &dev_info); + + if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen)) + return -EINVAL; + + /* update max frame size */ + dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size; + + return 0; +} + static int atl_dev_set_mc_addr_list(struct rte_eth_dev *dev, struct ether_addr *mc_addr_set, -- 2.20.1