common/sfc_efx/base: add mport alias MCDI wrappers
[dpdk.git] / drivers / common / sfc_efx / base / ef10_filter.c
index 51e6f1a..6d19797 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2019-2021 Xilinx, Inc.
  * Copyright(c) 2007-2019 Solarflare Communications Inc.
  */
 
@@ -171,6 +171,7 @@ efx_mcdi_filter_op_add(
        EFX_MCDI_DECLARE_BUF(payload, MC_CMD_FILTER_OP_V3_IN_LEN,
                MC_CMD_FILTER_OP_EXT_OUT_LEN);
        efx_filter_match_flags_t match_flags;
+       uint32_t port_id;
        efx_rc_t rc;
 
        req.emr_cmd = MC_CMD_FILTER_OP;
@@ -180,10 +181,11 @@ efx_mcdi_filter_op_add(
        req.emr_out_length = MC_CMD_FILTER_OP_EXT_OUT_LEN;
 
        /*
-        * Remove match flag for encapsulated filters that does not correspond
+        * Remove EFX match flags that do not correspond
         * to the MCDI match flags
         */
        match_flags = spec->efs_match_flags & ~EFX_FILTER_MATCH_ENCAP_TYPE;
+       match_flags &= ~EFX_FILTER_MATCH_MPORT;
 
        switch (filter_op) {
        case MC_CMD_FILTER_OP_IN_OP_REPLACE:
@@ -202,7 +204,12 @@ efx_mcdi_filter_op_add(
                goto fail1;
        }
 
-       MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_PORT_ID, enp->en_vport_id);
+       if (spec->efs_match_flags & EFX_FILTER_MATCH_MPORT)
+               port_id = spec->efs_ingress_mport;
+       else
+               port_id = enp->en_vport_id;
+
+       MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_PORT_ID, port_id);
        MCDI_IN_SET_DWORD(req, FILTER_OP_EXT_IN_MATCH_FIELDS,
            match_flags);
        if (spec->efs_dmaq_id == EFX_FILTER_SPEC_RX_DMAQ_ID_DROP) {
@@ -1225,20 +1232,25 @@ efx_mcdi_get_parser_disp_info(
                goto fail1;
        }
 
+       if (req.emr_out_length_used < MC_CMD_GET_PARSER_DISP_INFO_OUT_LENMIN) {
+               rc = EMSGSIZE;
+               goto fail2;
+       }
+
        matches_count = MCDI_OUT_DWORD(req,
            GET_PARSER_DISP_INFO_OUT_NUM_SUPPORTED_MATCHES);
 
        if (req.emr_out_length_used <
            MC_CMD_GET_PARSER_DISP_INFO_OUT_LEN(matches_count)) {
                rc = EMSGSIZE;
-               goto fail2;
+               goto fail3;
        }
 
        *list_lengthp = matches_count;
 
        if (buffer_length < matches_count) {
                rc = ENOSPC;
-               goto fail3;
+               goto fail4;
        }
 
        /*
@@ -1258,6 +1270,8 @@ efx_mcdi_get_parser_disp_info(
 
        return (0);
 
+fail4:
+       EFSYS_PROBE(fail4);
 fail3:
        EFSYS_PROBE(fail3);
 fail2:
@@ -1328,9 +1342,15 @@ ef10_filter_supported_filters(
                rc = efx_mcdi_get_parser_disp_info(enp, &buffer[next_buf_idx],
                    next_buf_length, B_TRUE, &mcdi_encap_list_length);
                if (rc != 0) {
-                       if (rc == ENOSPC)
+                       if (rc == ENOSPC) {
                                no_space = B_TRUE;
-                       else
+                       } else if (rc == EINVAL) {
+                               /*
+                                * Do not fail if the MCDI do not recognize the
+                                * query for encapsulated packet filters.
+                                */
+                               mcdi_encap_list_length = 0;
+                       } else
                                goto fail2;
                } else {
                        for (i = next_buf_idx;