net/liquidio: add API to control Rx
authorShijith Thotton <shijith.thotton@caviumnetworks.com>
Sat, 25 Mar 2017 06:24:44 +0000 (11:54 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 4 Apr 2017 16:59:49 +0000 (18:59 +0200)
Enable or disable packet reception.

Signed-off-by: Shijith Thotton <shijith.thotton@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Derek Chickles <derek.chickles@caviumnetworks.com>
Signed-off-by: Venkat Koppula <venkat.koppula@caviumnetworks.com>
Signed-off-by: Srisivasubramanian S <ssrinivasan@caviumnetworks.com>
Signed-off-by: Mallesham Jatharakonda <mjatharakonda@oneconvergence.com>
drivers/net/liquidio/base/lio_hw_defs.h
drivers/net/liquidio/lio_ethdev.c

index d38c835..59668c0 100644 (file)
@@ -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
index 4962cad..c698c70 100644 (file)
 #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;
 }