net/cxgbe: add flow ops to match based on dest MAC
[dpdk.git] / drivers / net / cxgbe / cxgbe_main.c
index c3f0053..9c40f51 100644 (file)
@@ -38,6 +38,8 @@
 #include "t4_msg.h"
 #include "cxgbe.h"
 #include "clip_tbl.h"
+#include "l2t.h"
+#include "mps_tcam.h"
 
 /**
  * Allocate a chunk of memory. The allocated memory is cleared.
@@ -99,6 +101,10 @@ static int fwevtq_handler(struct sge_rspq *q, const __be64 *rsp,
                const struct cpl_act_open_rpl *p = (const void *)rsp;
 
                hash_filter_rpl(q->adapter, p);
+       } else if (opcode == CPL_L2T_WRITE_RPL) {
+               const struct cpl_l2t_write_rpl *p = (const void *)rsp;
+
+               do_l2t_write_rpl(q->adapter, p);
        } else {
                dev_err(adapter, "unexpected CPL %#x on FW event queue\n",
                        opcode);
@@ -513,7 +519,7 @@ void cfg_queues(struct rte_eth_dev *eth_dev)
                 * We default up to # of cores queues per 1G/10G port.
                 */
                if (nb_ports)
-                       q_per_port = (MAX_ETH_QSETS -
+                       q_per_port = (s->max_ethqsets -
                                     (adap->params.nports - nb_ports)) /
                                     nb_ports;
 
@@ -537,8 +543,6 @@ void cfg_queues(struct rte_eth_dev *eth_dev)
                        qidx += pi->n_rx_qsets;
                }
 
-               s->max_ethqsets = qidx;
-
                for (i = 0; i < ARRAY_SIZE(s->ethrxq); i++) {
                        struct sge_eth_rxq *r = &s->ethrxq[i];
 
@@ -770,6 +774,40 @@ static void configure_pcie_ext_tag(struct adapter *adapter)
        }
 }
 
+/* Figure out how many Queue Sets we can support */
+void configure_max_ethqsets(struct adapter *adapter)
+{
+       unsigned int ethqsets;
+
+       /*
+        * We need to reserve an Ingress Queue for the Asynchronous Firmware
+        * Event Queue.
+        *
+        * For each Queue Set, we'll need the ability to allocate two Egress
+        * Contexts -- one for the Ingress Queue Free List and one for the TX
+        * Ethernet Queue.
+        */
+       if (is_pf4(adapter)) {
+               struct pf_resources *pfres = &adapter->params.pfres;
+
+               ethqsets = pfres->niqflint - 1;
+               if (pfres->neq < ethqsets * 2)
+                       ethqsets = pfres->neq / 2;
+       } else {
+               struct vf_resources *vfres = &adapter->params.vfres;
+
+               ethqsets = vfres->niqflint - 1;
+               if (vfres->nethctrl != ethqsets)
+                       ethqsets = min(vfres->nethctrl, ethqsets);
+               if (vfres->neq < ethqsets * 2)
+                       ethqsets = vfres->neq / 2;
+       }
+
+       if (ethqsets > MAX_ETH_QSETS)
+               ethqsets = MAX_ETH_QSETS;
+       adapter->sge.max_ethqsets = ethqsets;
+}
+
 /*
  * Tweak configuration based on system architecture, etc.  Most of these have
  * defaults assigned to them by Firmware Configuration Files (if we're using
@@ -1051,6 +1089,17 @@ static int adap_init0(struct adapter *adap)
                goto bye;
        }
 
+       /* Now that we've successfully configured and initialized the adapter
+        * (or found it already initialized), we can ask the Firmware what
+        * resources it has provisioned for us.
+        */
+       ret = t4_get_pfres(adap);
+       if (ret) {
+               dev_err(adap->pdev_dev,
+                       "Unable to retrieve resource provisioning info\n");
+               goto bye;
+       }
+
        /* Find out what ports are available to us. */
        v = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) |
            V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_PORTVEC);
@@ -1092,13 +1141,17 @@ static int adap_init0(struct adapter *adap)
         V_FW_PARAMS_PARAM_Y(0) | \
         V_FW_PARAMS_PARAM_Z(0))
 
-       params[0] = FW_PARAM_PFVF(FILTER_START);
-       params[1] = FW_PARAM_PFVF(FILTER_END);
-       ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 2, params, val);
+       params[0] = FW_PARAM_PFVF(L2T_START);
+       params[1] = FW_PARAM_PFVF(L2T_END);
+       params[2] = FW_PARAM_PFVF(FILTER_START);
+       params[3] = FW_PARAM_PFVF(FILTER_END);
+       ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 4, params, val);
        if (ret < 0)
                goto bye;
-       adap->tids.ftid_base = val[0];
-       adap->tids.nftids = val[1] - val[0] + 1;
+       adap->l2t_start = val[0];
+       adap->l2t_end = val[1];
+       adap->tids.ftid_base = val[2];
+       adap->tids.nftids = val[3] - val[2] + 1;
 
        params[0] = FW_PARAM_PFVF(CLIP_START);
        params[1] = FW_PARAM_PFVF(CLIP_END);
@@ -1201,6 +1254,7 @@ static int adap_init0(struct adapter *adap)
        t4_init_tp_params(adap);
        configure_pcie_ext_tag(adap);
        configure_vlan_types(adap);
+       configure_max_ethqsets(adap);
 
        adap->params.drv_memwin = MEMWIN_NIC;
        adap->flags |= FW_OK;
@@ -1288,10 +1342,8 @@ int link_start(struct port_info *pi)
        ret = t4_set_rxmode(adapter, adapter->mbox, pi->viid, mtu, -1, -1,
                            -1, 1, true);
        if (ret == 0) {
-               ret = t4_change_mac(adapter, adapter->mbox, pi->viid,
-                                   pi->xact_addr_filt,
-                                   (u8 *)&pi->eth_dev->data->mac_addrs[0],
-                                   true, true);
+               ret = cxgbe_mpstcam_modify(pi, (int)pi->xact_addr_filt,
+                               (u8 *)&pi->eth_dev->data->mac_addrs[0]);
                if (ret >= 0) {
                        pi->xact_addr_filt = ret;
                        ret = 0;
@@ -1635,10 +1687,12 @@ void cxgbe_close(struct adapter *adapter)
        int i;
 
        if (adapter->flags & FULL_INIT_DONE) {
-               if (is_pf4(adapter))
-                       t4_intr_disable(adapter);
                tid_free(&adapter->tids);
+               t4_cleanup_mpstcam(adapter);
                t4_cleanup_clip_tbl(adapter);
+               t4_cleanup_l2t(adapter);
+               if (is_pf4(adapter))
+                       t4_intr_disable(adapter);
                t4_sge_tx_monitor_stop(adapter);
                t4_free_sge_resources(adapter);
                for_each_port(adapter, i) {
@@ -1811,12 +1865,23 @@ allocate_mac:
                dev_warn(adapter, "could not allocate CLIP. Continuing\n");
        }
 
+       adapter->l2t = t4_init_l2t(adapter->l2t_start, adapter->l2t_end);
+       if (!adapter->l2t) {
+               /* We tolerate a lack of L2T, giving up some functionality */
+               dev_warn(adapter, "could not allocate L2T. Continuing\n");
+       }
+
        if (tid_init(&adapter->tids) < 0) {
                /* Disable filtering support */
                dev_warn(adapter, "could not allocate TID table, "
                         "filter support disabled. Continuing\n");
        }
 
+       adapter->mpstcam = t4_init_mpstcam(adapter);
+       if (!adapter->mpstcam)
+               dev_warn(adapter, "could not allocate mps tcam table."
+                        " Continuing\n");
+
        if (is_hashfilter(adapter)) {
                if (t4_read_reg(adapter, A_LE_DB_CONFIG) & F_HASHEN) {
                        u32 hash_base, hash_reg;