From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shijith Thotton Subject: [PATCH v3 36/46] net/liquidio: add API to validate VF MTU Date: Sat, 25 Mar 2017 11:54:47 +0530 Message-ID: <1490423097-6797-37-git-send-email-shijith.thotton@caviumnetworks.com> References: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda To: Ferruh Yigit Return-path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0043.outbound.protection.outlook.com [104.47.36.43]) by dpdk.org (Postfix) with ESMTP id 90F52D466 for ; Sat, 25 Mar 2017 07:28:46 +0100 (CET) In-Reply-To: <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Shijith Thotton Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Srisivasubramanian S Signed-off-by: Mallesham Jatharakonda --- drivers/net/liquidio/lio_ethdev.c | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index e2040b9..560f195 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -152,6 +152,33 @@ } static int +lio_dev_validate_vf_mtu(struct rte_eth_dev *eth_dev, uint16_t new_mtu) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + + PMD_INIT_FUNC_TRACE(); + + if (!lio_dev->intf_open) { + lio_dev_err(lio_dev, "Port %d down, can't check MTU\n", + lio_dev->port_id); + return -EINVAL; + } + + /* Limit the MTU to make sure the ethernet packets are between + * ETHER_MIN_MTU bytes and PF's MTU + */ + if ((new_mtu < ETHER_MIN_MTU) || + (new_mtu > lio_dev->linfo.link.s.mtu)) { + lio_dev_err(lio_dev, "Invalid MTU: %d\n", new_mtu); + lio_dev_err(lio_dev, "Valid range %d and %d\n", + ETHER_MIN_MTU, lio_dev->linfo.link.s.mtu); + return -EINVAL; + } + + return 0; +} + +static int lio_dev_rss_reta_update(struct rte_eth_dev *eth_dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size) @@ -824,7 +851,9 @@ static int lio_dev_start(struct rte_eth_dev *eth_dev) { + uint16_t mtu = eth_dev->data->dev_conf.rxmode.max_rx_pkt_len; struct lio_device *lio_dev = LIO_DEV(eth_dev); + uint16_t timeout = LIO_MAX_CMD_TIMEOUT; int ret = 0; lio_dev_info(lio_dev, "Starting port %d\n", eth_dev->data->port_id); @@ -852,8 +881,25 @@ goto dev_lsc_handle_error; } + while ((lio_dev->linfo.link.link_status64 == 0) && (--timeout)) + rte_delay_ms(1); + + if (lio_dev->linfo.link.link_status64 == 0) { + ret = -1; + goto dev_mtu_check_error; + } + + if (lio_dev->linfo.link.s.mtu != mtu) { + ret = lio_dev_validate_vf_mtu(eth_dev, mtu); + if (ret) + goto dev_mtu_check_error; + } + return 0; +dev_mtu_check_error: + rte_eal_alarm_cancel(lio_sync_link_state_check, eth_dev); + dev_lsc_handle_error: lio_dev->intf_open = 0; lio_send_rx_ctrl_cmd(eth_dev, 0); -- 1.8.3.1