From: Shijith Thotton Date: Sat, 25 Mar 2017 06:24:44 +0000 (+0530) Subject: net/liquidio: add API to control Rx X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=432dbfde1d3d0c48072a6272ca7af0ae9bc7237f;p=dpdk.git net/liquidio: add API to control Rx Enable or disable packet reception. 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 --- diff --git a/drivers/net/liquidio/base/lio_hw_defs.h b/drivers/net/liquidio/base/lio_hw_defs.h index d38c835208..59668c047e 100644 --- a/drivers/net/liquidio/base/lio_hw_defs.h +++ b/drivers/net/liquidio/base/lio_hw_defs.h @@ -128,6 +128,9 @@ enum octeon_tag_type { #define LIO_MAX_RX_PKTLEN (64 * 1024) +/* NIC Command types */ +#define LIO_CMD_RX_CTL 0x4 + /* RX(packets coming from wire) Checksum verification flags */ /* TCP/UDP csum */ #define LIO_L4_CSUM_VERIFIED 0x1 diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index 4962cad775..c698c70497 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -41,6 +41,61 @@ #include "lio_ethdev.h" #include "lio_rxtx.h" +/* Wait for control command to reach nic. */ +static uint16_t +lio_wait_for_ctrl_cmd(struct lio_device *lio_dev, + struct lio_dev_ctrl_cmd *ctrl_cmd) +{ + uint16_t timeout = LIO_MAX_CMD_TIMEOUT; + + while ((ctrl_cmd->cond == 0) && --timeout) { + lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); + rte_delay_ms(1); + } + + return !timeout; +} + +/** + * \brief Send Rx control command + * @param eth_dev Pointer to the structure rte_eth_dev + * @param start_stop whether to start or stop + */ +static int +lio_send_rx_ctrl_cmd(struct rte_eth_dev *eth_dev, int start_stop) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + struct lio_dev_ctrl_cmd ctrl_cmd; + struct lio_ctrl_pkt ctrl_pkt; + + /* flush added to prevent cmd failure + * incase the queue is full + */ + lio_flush_iq(lio_dev, lio_dev->instr_queue[0]); + + memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt)); + memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd)); + + ctrl_cmd.eth_dev = eth_dev; + ctrl_cmd.cond = 0; + + ctrl_pkt.ncmd.s.cmd = LIO_CMD_RX_CTL; + ctrl_pkt.ncmd.s.param1 = start_stop; + ctrl_pkt.ctrl_cmd = &ctrl_cmd; + + if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) { + lio_dev_err(lio_dev, "Failed to send RX Control message\n"); + return -1; + } + + if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) { + lio_dev_err(lio_dev, "RX Control command timed out\n"); + return -1; + } + + return 0; +} + /** * Atomically writes the link status information into global * structure rte_eth_dev. @@ -402,6 +457,9 @@ lio_dev_start(struct rte_eth_dev *eth_dev) if (lio_dev->fn_list.enable_io_queues(lio_dev)) return -1; + if (lio_send_rx_ctrl_cmd(eth_dev, 1)) + return -1; + /* Ready for link status updates */ lio_dev->intf_open = 1; rte_mb(); @@ -420,6 +478,7 @@ lio_dev_start(struct rte_eth_dev *eth_dev) dev_lsc_handle_error: lio_dev->intf_open = 0; + lio_send_rx_ctrl_cmd(eth_dev, 0); return ret; }