net/ngbe: support MAC filters
[dpdk.git] / drivers / net / sfc / sfc_dp.c
index 860aa92..d4cd162 100644 (file)
@@ -1,32 +1,10 @@
-/*-
- *   BSD LICENSE
+/* SPDX-License-Identifier: BSD-3-Clause
  *
- * Copyright (c) 2017 Solarflare Communications Inc.
- * All rights reserved.
+ * Copyright(c) 2019-2021 Xilinx, Inc.
+ * Copyright(c) 2017-2019 Solarflare Communications Inc.
  *
  * This software was jointly developed between OKTET Labs (under contract
  * for Solarflare) and Solarflare Communications, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include <sys/queue.h>
 #include <errno.h>
 
 #include <rte_log.h>
+#include <rte_mbuf_dyn.h>
+
+#include "efx.h"
 
 #include "sfc_dp.h"
+#include "sfc_log.h"
 
 void
 sfc_dp_queue_init(struct sfc_dp_queue *dpq, uint16_t port_id, uint16_t queue_id,
@@ -85,8 +67,8 @@ int
 sfc_dp_register(struct sfc_dp_list *head, struct sfc_dp *entry)
 {
        if (sfc_dp_find_by_name(head, entry->type, entry->name) != NULL) {
-               rte_log(RTE_LOG_ERR, RTE_LOGTYPE_PMD,
-                       "sfc %s dapapath '%s' already registered\n",
+               SFC_GENERIC_LOG(ERR,
+                       "sfc %s dapapath '%s' already registered",
                        entry->type == SFC_DP_RX ? "Rx" :
                        entry->type == SFC_DP_TX ? "Tx" :
                        "unknown",
@@ -98,3 +80,93 @@ sfc_dp_register(struct sfc_dp_list *head, struct sfc_dp *entry)
 
        return 0;
 }
+
+uint64_t sfc_dp_mport_override;
+int sfc_dp_mport_offset = -1;
+
+int
+sfc_dp_mport_register(void)
+{
+       static const struct rte_mbuf_dynfield mport = {
+               .name = "rte_net_sfc_dynfield_mport",
+               .size = sizeof(efx_mport_id_t),
+               .align = __alignof__(efx_mport_id_t),
+       };
+       static const struct rte_mbuf_dynflag mport_override = {
+               .name = "rte_net_sfc_dynflag_mport_override",
+       };
+
+       int field_offset;
+       int flag;
+
+       if (sfc_dp_mport_override != 0) {
+               SFC_GENERIC_LOG(INFO, "%s() already registered", __func__);
+               return 0;
+       }
+
+       field_offset = rte_mbuf_dynfield_register(&mport);
+       if (field_offset < 0) {
+               SFC_GENERIC_LOG(ERR, "%s() failed to register mport dynfield",
+                               __func__);
+               return -1;
+       }
+
+       flag = rte_mbuf_dynflag_register(&mport_override);
+       if (flag < 0) {
+               SFC_GENERIC_LOG(ERR, "%s() failed to register mport dynflag",
+                               __func__);
+               return -1;
+       }
+
+       sfc_dp_mport_offset = field_offset;
+       sfc_dp_mport_override = UINT64_C(1) << flag;
+
+       return 0;
+}
+
+int sfc_dp_ft_id_offset = -1;
+uint64_t sfc_dp_ft_id_valid;
+
+int
+sfc_dp_ft_id_register(void)
+{
+       static const struct rte_mbuf_dynfield ft_id = {
+               .name = "rte_net_sfc_dynfield_ft_id",
+               .size = sizeof(uint8_t),
+               .align = __alignof__(uint8_t),
+       };
+       static const struct rte_mbuf_dynflag ft_id_valid = {
+               .name = "rte_net_sfc_dynflag_ft_id_valid",
+       };
+
+       int field_offset;
+       int flag;
+
+       SFC_GENERIC_LOG(INFO, "%s() entry", __func__);
+
+       if (sfc_dp_ft_id_valid != 0) {
+               SFC_GENERIC_LOG(INFO, "%s() already registered", __func__);
+               return 0;
+       }
+
+       field_offset = rte_mbuf_dynfield_register(&ft_id);
+       if (field_offset < 0) {
+               SFC_GENERIC_LOG(ERR, "%s() failed to register ft_id dynfield",
+                               __func__);
+               return -1;
+       }
+
+       flag = rte_mbuf_dynflag_register(&ft_id_valid);
+       if (flag < 0) {
+               SFC_GENERIC_LOG(ERR, "%s() failed to register ft_id dynflag",
+                               __func__);
+               return -1;
+       }
+
+       sfc_dp_ft_id_offset = field_offset;
+       sfc_dp_ft_id_valid = UINT64_C(1) << flag;
+
+       SFC_GENERIC_LOG(INFO, "%s() done", __func__);
+
+       return 0;
+}