net/sfc: support flow API filters
[dpdk.git] / drivers / net / sfc / sfc.c
index 457a53e..3e419b6 100644 (file)
@@ -203,6 +203,13 @@ sfc_estimate_resource_limits(struct sfc_adapter *sa)
        limits.edl_max_txq_count =
                MIN(encp->enc_txq_limit,
                    limits.edl_max_evq_count - 1 - limits.edl_max_rxq_count);
+
+       if (sa->tso)
+               limits.edl_max_txq_count =
+                       MIN(limits.edl_max_txq_count,
+                           encp->enc_fw_assisted_tso_v2_n_contexts /
+                           encp->enc_hw_pf_count);
+
        SFC_ASSERT(limits.edl_max_txq_count >= limits.edl_min_rxq_count);
 
        /* Configure the minimum required resources needed for the
@@ -313,10 +320,17 @@ sfc_start(struct sfc_adapter *sa)
        if (rc != 0)
                goto fail_tx_start;
 
+       rc = sfc_flow_start(sa);
+       if (rc != 0)
+               goto fail_flows_insert;
+
        sa->state = SFC_ADAPTER_STARTED;
        sfc_log_init(sa, "done");
        return 0;
 
+fail_flows_insert:
+       sfc_tx_stop(sa);
+
 fail_tx_start:
        sfc_rx_stop(sa);
 
@@ -361,6 +375,7 @@ sfc_stop(struct sfc_adapter *sa)
 
        sa->state = SFC_ADAPTER_STOPPING;
 
+       sfc_flow_stop(sa);
        sfc_tx_stop(sa);
        sfc_rx_stop(sa);
        sfc_port_stop(sa);
@@ -601,12 +616,17 @@ sfc_attach(struct sfc_adapter *sa)
        if (rc != 0)
                goto fail_nic_reset;
 
+       encp = efx_nic_cfg_get(sa->nic);
+
+       sa->tso = encp->enc_fw_assisted_tso_v2_enabled;
+       if (!sa->tso)
+               sfc_warn(sa, "TSO support isn't available on this adapter");
+
        sfc_log_init(sa, "estimate resource limits");
        rc = sfc_estimate_resource_limits(sa);
        if (rc != 0)
                goto fail_estimate_rsrc_limits;
 
-       encp = efx_nic_cfg_get(sa->nic);
        sa->txq_max_entries = encp->enc_txq_max_ndescs;
        SFC_ASSERT(rte_is_power_of_2(sa->txq_max_entries));
 
@@ -621,18 +641,21 @@ sfc_attach(struct sfc_adapter *sa)
        if (rc != 0)
                goto fail_set_rss_defaults;
 
-       sa->tso = efx_nic_cfg_get(sa->nic)->enc_fw_assisted_tso_v2_enabled;
-       if (!sa->tso)
-               sfc_warn(sa, "TSO support isn't available on this adapter");
+       rc = sfc_filter_attach(sa);
+       if (rc != 0)
+               goto fail_filter_attach;
 
        sfc_log_init(sa, "fini nic");
        efx_nic_fini(enp);
 
+       sfc_flow_init(sa);
+
        sa->state = SFC_ADAPTER_INITIALIZED;
 
        sfc_log_init(sa, "done");
        return 0;
 
+fail_filter_attach:
 fail_set_rss_defaults:
        sfc_intr_detach(sa);
 
@@ -670,6 +693,8 @@ sfc_detach(struct sfc_adapter *sa)
 
        SFC_ASSERT(sfc_adapter_is_locked(sa));
 
+       sfc_filter_detach(sa);
+
        sfc_intr_detach(sa);
 
        sfc_log_init(sa, "unprobe nic");
@@ -683,5 +708,6 @@ sfc_detach(struct sfc_adapter *sa)
 
        sfc_mem_bar_fini(sa);
 
+       sfc_flow_fini(sa);
        sa->state = SFC_ADAPTER_UNINITIALIZED;
 }