Commit 9b7fe804 authored by Bin Chen's avatar Bin Chen Committed by Jakub Kicinski

nfp: add DCB IEEE support

Add basic DCB IEEE support. This includes support for ETS, max-rate,
and DSCP to user priority mapping.

DCB may be configured using iproute2's dcb command.
Example usage:
  dcb ets set dev $dev tc-tsa 0:ets 1:ets 2:ets 3:ets 4:ets 5:ets \
    6:ets 7:ets tc-bw 0:0 1:80 2:0 3:0 4:0 5:0 6:20 7:0
  dcb maxrate set dev $dev tc-maxrate 1:1000bit

And DCB configuration can be shown using:
  dcb ets show dev $dev
  dcb maxrate show dev $dev
Signed-off-by: default avatarBin Chen <bin.chen@corigine.com>
Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230112121102.469739-1-simon.horman@corigine.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent bf20ce9f
...@@ -83,3 +83,5 @@ endif ...@@ -83,3 +83,5 @@ endif
nfp-$(CONFIG_NFP_NET_IPSEC) += crypto/ipsec.o nfd3/ipsec.o nfp-$(CONFIG_NFP_NET_IPSEC) += crypto/ipsec.o nfd3/ipsec.o
nfp-$(CONFIG_NFP_DEBUG) += nfp_net_debugfs.o nfp-$(CONFIG_NFP_DEBUG) += nfp_net_debugfs.o
nfp-$(CONFIG_DCB) += nic/dcb.o
...@@ -413,6 +413,7 @@ ...@@ -413,6 +413,7 @@
#define NFP_NET_CFG_MBOX_CMD_IPSEC 3 #define NFP_NET_CFG_MBOX_CMD_IPSEC 3
#define NFP_NET_CFG_MBOX_CMD_PCI_DSCP_PRIOMAP_SET 5 #define NFP_NET_CFG_MBOX_CMD_PCI_DSCP_PRIOMAP_SET 5
#define NFP_NET_CFG_MBOX_CMD_TLV_CMSG 6 #define NFP_NET_CFG_MBOX_CMD_TLV_CMSG 6
#define NFP_NET_CFG_MBOX_CMD_DCB_UPDATE 7
#define NFP_NET_CFG_MBOX_CMD_MULTICAST_ADD 8 #define NFP_NET_CFG_MBOX_CMD_MULTICAST_ADD 8
#define NFP_NET_CFG_MBOX_CMD_MULTICAST_DEL 9 #define NFP_NET_CFG_MBOX_CMD_MULTICAST_DEL 9
......
This diff is collapsed.
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "../nfpcore/nfp_nsp.h" #include "../nfpcore/nfp_nsp.h"
#include "../nfp_app.h" #include "../nfp_app.h"
#include "../nfp_main.h" #include "../nfp_main.h"
#include "../nfp_net.h"
#include "main.h"
static int nfp_nic_init(struct nfp_app *app) static int nfp_nic_init(struct nfp_app *app)
{ {
...@@ -28,13 +30,46 @@ static void nfp_nic_sriov_disable(struct nfp_app *app) ...@@ -28,13 +30,46 @@ static void nfp_nic_sriov_disable(struct nfp_app *app)
{ {
} }
static int nfp_nic_vnic_init(struct nfp_app *app, struct nfp_net *nn)
{
nfp_nic_dcb_init(nn);
return 0;
}
static int nfp_nic_vnic_alloc(struct nfp_app *app, struct nfp_net *nn,
unsigned int id)
{
struct nfp_app_nic_private *app_pri = nn->app_priv;
int err;
err = nfp_app_nic_vnic_alloc(app, nn, id);
if (err)
return err;
if (sizeof(*app_pri)) {
nn->app_priv = kzalloc(sizeof(*app_pri), GFP_KERNEL);
if (!nn->app_priv)
return -ENOMEM;
}
return 0;
}
static void nfp_nic_vnic_free(struct nfp_app *app, struct nfp_net *nn)
{
kfree(nn->app_priv);
}
const struct nfp_app_type app_nic = { const struct nfp_app_type app_nic = {
.id = NFP_APP_CORE_NIC, .id = NFP_APP_CORE_NIC,
.name = "nic", .name = "nic",
.init = nfp_nic_init, .init = nfp_nic_init,
.vnic_alloc = nfp_app_nic_vnic_alloc, .vnic_alloc = nfp_nic_vnic_alloc,
.vnic_free = nfp_nic_vnic_free,
.sriov_enable = nfp_nic_sriov_enable, .sriov_enable = nfp_nic_sriov_enable,
.sriov_disable = nfp_nic_sriov_disable, .sriov_disable = nfp_nic_sriov_disable,
.vnic_init = nfp_nic_vnic_init,
}; };
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
/* Copyright (C) 2023 Corigine, Inc. */
#ifndef __NFP_NIC_H__
#define __NFP_NIC_H__ 1
#include <linux/netdevice.h>
#ifdef CONFIG_DCB
/* DCB feature definitions */
#define NFP_NET_MAX_DSCP 4
#define NFP_NET_MAX_TC IEEE_8021QAZ_MAX_TCS
#define NFP_NET_MAX_PRIO 8
#define NFP_DCB_CFG_STRIDE 256
struct nfp_dcb {
u8 dscp2prio[NFP_NET_MAX_DSCP];
u8 prio2tc[NFP_NET_MAX_PRIO];
u8 tc2idx[IEEE_8021QAZ_MAX_TCS];
u64 tc_maxrate[IEEE_8021QAZ_MAX_TCS];
u8 tc_tx_pct[IEEE_8021QAZ_MAX_TCS];
u8 tc_tsa[IEEE_8021QAZ_MAX_TCS];
u8 dscp_cnt;
u8 trust_status;
bool rate_init;
bool ets_init;
struct nfp_cpp_area *dcbcfg_tbl_area;
u8 __iomem *dcbcfg_tbl;
u32 cfg_offset;
};
int nfp_nic_dcb_init(struct nfp_net *nn);
void nfp_nic_dcb_clean(struct nfp_net *nn);
#else
static inline int nfp_nic_dcb_init(struct nfp_net *nn) {return 0; }
static inline void nfp_nic_dcb_clean(struct nfp_net *nn) {}
#endif
struct nfp_app_nic_private {
#ifdef CONFIG_DCB
struct nfp_dcb dcb;
#endif
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment