doc: add octeontx mempool guide
[dpdk.git] / drivers / net / cxgbe / cxgbe_main.c
index 2522354..5b828c2 100644 (file)
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_memory.h>
-#include <rte_memzone.h>
 #include <rte_tailq.h>
 #include <rte_eal.h>
 #include <rte_alarm.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_ethdev_pci.h>
-#include <rte_atomic.h>
 #include <rte_malloc.h>
 #include <rte_random.h>
 #include <rte_dev.h>
@@ -414,6 +412,36 @@ static void print_port_info(struct adapter *adap)
        }
 }
 
+static void configure_pcie_ext_tag(struct adapter *adapter)
+{
+       u16 v;
+       int pos = t4_os_find_pci_capability(adapter, PCI_CAP_ID_EXP);
+
+       if (!pos)
+               return;
+
+       if (pos > 0) {
+               t4_os_pci_read_cfg2(adapter, pos + PCI_EXP_DEVCTL, &v);
+               v |= PCI_EXP_DEVCTL_EXT_TAG;
+               t4_os_pci_write_cfg2(adapter, pos + PCI_EXP_DEVCTL, v);
+               if (is_t6(adapter->params.chip)) {
+                       t4_set_reg_field(adapter, A_PCIE_CFG2,
+                                        V_T6_TOTMAXTAG(M_T6_TOTMAXTAG),
+                                        V_T6_TOTMAXTAG(7));
+                       t4_set_reg_field(adapter, A_PCIE_CMD_CFG,
+                                        V_T6_MINTAG(M_T6_MINTAG),
+                                        V_T6_MINTAG(8));
+               } else {
+                       t4_set_reg_field(adapter, A_PCIE_CFG2,
+                                        V_TOTMAXTAG(M_TOTMAXTAG),
+                                        V_TOTMAXTAG(3));
+                       t4_set_reg_field(adapter, A_PCIE_CMD_CFG,
+                                        V_MINTAG(M_MINTAG),
+                                        V_MINTAG(8));
+               }
+       }
+}
+
 /*
  * Tweak configuration based on system architecture, etc.  Most of these have
  * defaults assigned to them by Firmware Configuration Files (if we're using
@@ -596,7 +624,7 @@ static int adap_init0_config(struct adapter *adapter, int reset)
        /*
         * Return successfully and note that we're operating with parameters
         * not supplied by the driver, rather than from hard-wired
-        * initialization constants burried in the driver.
+        * initialization constants buried in the driver.
         */
        dev_info(adapter,
                 "Successfully configured using Firmware Configuration File \"%s\", version %#x, computed checksum %#x\n",
@@ -799,6 +827,7 @@ static int adap_init0(struct adapter *adap)
        }
        t4_init_sge_params(adap);
        t4_init_tp_params(adap);
+       configure_pcie_ext_tag(adap);
 
        adap->params.drv_memwin = MEMWIN_NIC;
        adap->flags |= FW_OK;
@@ -984,33 +1013,126 @@ int setup_rss(struct port_info *pi)
 /*
  * Enable NAPI scheduling and interrupt generation for all Rx queues.
  */
-static void enable_rx(struct adapter *adap)
+static void enable_rx(struct adapter *adap, struct sge_rspq *q)
 {
-       struct sge *s = &adap->sge;
-       struct sge_rspq *q = &s->fw_evtq;
-       int i, j;
-
        /* 0-increment GTS to start the timer and enable interrupts */
        t4_write_reg(adap, MYPF_REG(A_SGE_PF_GTS),
                     V_SEINTARM(q->intr_params) |
                     V_INGRESSQID(q->cntxt_id));
+}
 
-       for_each_port(adap, i) {
-               const struct port_info *pi = &adap->port[i];
-               struct rte_eth_dev *eth_dev = pi->eth_dev;
-
-               for (j = 0; j < eth_dev->data->nb_rx_queues; j++) {
-                       q = eth_dev->data->rx_queues[j];
-
-                       /*
-                        * 0-increment GTS to start the timer and enable
-                        * interrupts
-                        */
-                       t4_write_reg(adap, MYPF_REG(A_SGE_PF_GTS),
-                                    V_SEINTARM(q->intr_params) |
-                                    V_INGRESSQID(q->cntxt_id));
-               }
+void cxgbe_enable_rx_queues(struct port_info *pi)
+{
+       struct adapter *adap = pi->adapter;
+       struct sge *s = &adap->sge;
+       unsigned int i;
+
+       for (i = 0; i < pi->n_rx_qsets; i++)
+               enable_rx(adap, &s->ethrxq[pi->first_qset + i].rspq);
+}
+
+/**
+ * fw_caps_to_speed_caps - translate Firmware Port Caps to Speed Caps.
+ * @port_type: Firmware Port Type
+ * @fw_caps: Firmware Port Capabilities
+ * @speed_caps: Device Info Speed Capabilities
+ *
+ * Translate a Firmware Port Capabilities specification to Device Info
+ * Speed Capabilities.
+ */
+static void fw_caps_to_speed_caps(enum fw_port_type port_type,
+                                 unsigned int fw_caps,
+                                 u32 *speed_caps)
+{
+#define SET_SPEED(__speed_name) \
+       do { \
+               *speed_caps |= ETH_LINK_ ## __speed_name; \
+       } while (0)
+
+#define FW_CAPS_TO_SPEED(__fw_name) \
+       do { \
+               if (fw_caps & FW_PORT_CAP_ ## __fw_name) \
+                       SET_SPEED(__fw_name); \
+       } while (0)
+
+       switch (port_type) {
+       case FW_PORT_TYPE_BT_SGMII:
+       case FW_PORT_TYPE_BT_XFI:
+       case FW_PORT_TYPE_BT_XAUI:
+               FW_CAPS_TO_SPEED(SPEED_100M);
+               FW_CAPS_TO_SPEED(SPEED_1G);
+               FW_CAPS_TO_SPEED(SPEED_10G);
+               break;
+
+       case FW_PORT_TYPE_KX4:
+       case FW_PORT_TYPE_KX:
+       case FW_PORT_TYPE_FIBER_XFI:
+       case FW_PORT_TYPE_FIBER_XAUI:
+       case FW_PORT_TYPE_SFP:
+       case FW_PORT_TYPE_QSFP_10G:
+       case FW_PORT_TYPE_QSA:
+               FW_CAPS_TO_SPEED(SPEED_1G);
+               FW_CAPS_TO_SPEED(SPEED_10G);
+               break;
+
+       case FW_PORT_TYPE_KR:
+               SET_SPEED(SPEED_10G);
+               break;
+
+       case FW_PORT_TYPE_BP_AP:
+       case FW_PORT_TYPE_BP4_AP:
+               SET_SPEED(SPEED_1G);
+               SET_SPEED(SPEED_10G);
+               break;
+
+       case FW_PORT_TYPE_BP40_BA:
+       case FW_PORT_TYPE_QSFP:
+               SET_SPEED(SPEED_40G);
+               break;
+
+       case FW_PORT_TYPE_CR_QSFP:
+       case FW_PORT_TYPE_SFP28:
+       case FW_PORT_TYPE_KR_SFP28:
+               FW_CAPS_TO_SPEED(SPEED_1G);
+               FW_CAPS_TO_SPEED(SPEED_10G);
+               FW_CAPS_TO_SPEED(SPEED_25G);
+               break;
+
+       case FW_PORT_TYPE_CR2_QSFP:
+               SET_SPEED(SPEED_50G);
+               break;
+
+       case FW_PORT_TYPE_KR4_100G:
+       case FW_PORT_TYPE_CR4_QSFP:
+               FW_CAPS_TO_SPEED(SPEED_25G);
+               FW_CAPS_TO_SPEED(SPEED_40G);
+               FW_CAPS_TO_SPEED(SPEED_100G);
+               break;
+
+       default:
+               break;
        }
+
+#undef FW_CAPS_TO_SPEED
+#undef SET_SPEED
+}
+
+/**
+ * cxgbe_get_speed_caps - Fetch supported speed capabilities
+ * @pi: Underlying port's info
+ * @speed_caps: Device Info speed capabilities
+ *
+ * Fetch supported speed capabilities of the underlying port.
+ */
+void cxgbe_get_speed_caps(struct port_info *pi, u32 *speed_caps)
+{
+       *speed_caps = 0;
+
+       fw_caps_to_speed_caps(pi->port_type, pi->link_cfg.supported,
+                             speed_caps);
+
+       if (!(pi->link_cfg.supported & FW_PORT_CAP_ANEG))
+               *speed_caps |= ETH_LINK_SPEED_FIXED;
 }
 
 /**
@@ -1023,7 +1145,7 @@ static void enable_rx(struct adapter *adap)
  */
 int cxgbe_up(struct adapter *adap)
 {
-       enable_rx(adap);
+       enable_rx(adap, &adap->sge.fw_evtq);
        t4_sge_tx_monitor_start(adap);
        t4_intr_enable(adap);
        adap->flags |= FULL_INIT_DONE;