linux/drivers/net/ethernet/freescale/enetc/ntmp_private.h

105 lines
2.3 KiB
C
Raw Permalink Normal View History

net: enetc: add initial netc-lib driver to support NTMP Some NETC functionality is controlled using control messages sent to the hardware using BD ring interface with 32B descriptor similar to transmit BD ring used on ENETC. This BD ring interface is referred to as command BD ring. It is used to configure functionality where the underlying resources may be shared between different entities or being too large to configure using direct registers. Therefore, a messaging protocol called NETC Table Management Protocol (NTMP) is provided for exchanging configuration and management information between the software and the hardware using the command BD ring interface. For the management protocol of LS1028A has been retroactively named NTMP 1.0, and its implementation is in enetc_cbdr.c and enetc_qos.c. However, NTMP of i.MX95 has been upgraded to version 2.0, which is incompatible with LS1028A, because the message formats have been changed. Therefore, add the netc-lib driver to support NTMP 2.0 to operate various tables. Note that, only MAC address filter table and RSS table are supported at the moment. More tables will be supported in subsequent patches. It is worth mentioning that the purpose of the netc-lib driver is to provide some NTMP-based generic interfaces for ENETC and NETC Switch drivers. Currently, it only supports the configurations of some tables. Interfaces such as tc flower and debugfs will be added in the future. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://patch.msgid.link/20250506080735.3444381-2-wei.fang@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-05-06 16:07:22 +08:00
/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
/*
* NTMP table request and response data buffer formats
* Copyright 2025 NXP
*/
#ifndef __NTMP_PRIVATE_H
#define __NTMP_PRIVATE_H
#include <linux/bitfield.h>
net: enetc: add initial netc-lib driver to support NTMP Some NETC functionality is controlled using control messages sent to the hardware using BD ring interface with 32B descriptor similar to transmit BD ring used on ENETC. This BD ring interface is referred to as command BD ring. It is used to configure functionality where the underlying resources may be shared between different entities or being too large to configure using direct registers. Therefore, a messaging protocol called NETC Table Management Protocol (NTMP) is provided for exchanging configuration and management information between the software and the hardware using the command BD ring interface. For the management protocol of LS1028A has been retroactively named NTMP 1.0, and its implementation is in enetc_cbdr.c and enetc_qos.c. However, NTMP of i.MX95 has been upgraded to version 2.0, which is incompatible with LS1028A, because the message formats have been changed. Therefore, add the netc-lib driver to support NTMP 2.0 to operate various tables. Note that, only MAC address filter table and RSS table are supported at the moment. More tables will be supported in subsequent patches. It is worth mentioning that the purpose of the netc-lib driver is to provide some NTMP-based generic interfaces for ENETC and NETC Switch drivers. Currently, it only supports the configurations of some tables. Interfaces such as tc flower and debugfs will be added in the future. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://patch.msgid.link/20250506080735.3444381-2-wei.fang@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-05-06 16:07:22 +08:00
#include <linux/fsl/ntmp.h>
#define NTMP_EID_REQ_LEN 8
#define NETC_CBDR_BD_NUM 256
union netc_cbd {
struct {
__le64 addr;
__le32 len;
#define NTMP_RESP_LEN GENMASK(19, 0)
#define NTMP_REQ_LEN GENMASK(31, 20)
#define NTMP_LEN(req, resp) (FIELD_PREP(NTMP_REQ_LEN, (req)) | \
((resp) & NTMP_RESP_LEN))
u8 cmd;
#define NTMP_CMD_DELETE BIT(0)
#define NTMP_CMD_UPDATE BIT(1)
#define NTMP_CMD_QUERY BIT(2)
#define NTMP_CMD_ADD BIT(3)
#define NTMP_CMD_QU (NTMP_CMD_QUERY | NTMP_CMD_UPDATE)
u8 access_method;
#define NTMP_ACCESS_METHOD GENMASK(7, 4)
#define NTMP_AM_ENTRY_ID 0
#define NTMP_AM_EXACT_KEY 1
#define NTMP_AM_SEARCH 2
#define NTMP_AM_TERNARY_KEY 3
u8 table_id;
u8 ver_cci_rr;
#define NTMP_HDR_VERSION GENMASK(5, 0)
#define NTMP_HDR_VER2 2
#define NTMP_CCI BIT(6)
#define NTMP_RR BIT(7)
__le32 resv[3];
__le32 npf;
#define NTMP_NPF BIT(15)
} req_hdr; /* NTMP Request Message Header Format */
struct {
__le32 resv0[3];
__le16 num_matched;
__le16 error_rr;
#define NTMP_RESP_ERROR GENMASK(11, 0)
#define NTMP_RESP_RR BIT(15)
__le32 resv1[4];
} resp_hdr; /* NTMP Response Message Header Format */
};
struct ntmp_dma_buf {
struct device *dev;
size_t size;
void *buf;
dma_addr_t dma;
};
struct ntmp_cmn_req_data {
__le16 update_act;
u8 dbg_opt;
u8 tblv_qact;
#define NTMP_QUERY_ACT GENMASK(3, 0)
#define NTMP_TBL_VER GENMASK(7, 4)
#define NTMP_TBLV_QACT(v, a) (FIELD_PREP(NTMP_TBL_VER, (v)) | \
((a) & NTMP_QUERY_ACT))
};
struct ntmp_cmn_resp_query {
__le32 entry_id;
};
/* Generic structure for request data by entry ID */
struct ntmp_req_by_eid {
struct ntmp_cmn_req_data crd;
__le32 entry_id;
};
/* MAC Address Filter Table Request Data Buffer Format of Add action */
struct maft_req_add {
struct ntmp_req_by_eid rbe;
struct maft_keye_data keye;
struct maft_cfge_data cfge;
};
/* MAC Address Filter Table Response Data Buffer Format of Query action */
struct maft_resp_query {
__le32 entry_id;
struct maft_keye_data keye;
struct maft_cfge_data cfge;
};
/* RSS Table Request Data Buffer Format of Update action */
struct rsst_req_update {
struct ntmp_req_by_eid rbe;
u8 groups[];
};
#endif