mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
net: enetc: add "Update" and "Delete" operations to VLAN filter table
Add two interfaces to manage entries in the VLAN filter table: ntmp_vft_update_entry(): Update the configuration element data of the specified VLAN filter entry based on the given VLAN ID. It uses the exact key access method to locate the entry. ntmp_vft_delete_entry(): Delete the VLAN filter entry corresponding to the specified VLAN ID. It also uses the exact key access method to identify the target entry. In addition, introduce struct vft_req_qd to describe the request data buffer format for Query and Delete actions of the VLAN filter table, which contains a common request data header and a VLAN access key. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260611021458.2629145-3-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
ca394837df
commit
c52b6702a9
|
|
@ -955,6 +955,51 @@ int ntmp_fdbt_delete_port_dynamic_entries(struct ntmp_user *user, int port)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(ntmp_fdbt_delete_port_dynamic_entries);
|
||||
|
||||
/**
|
||||
* ntmp_vft_set_entry - add an entry into the VLAN filter table or update
|
||||
* the configuration element data of the specified VLAN filter entry
|
||||
* @user: target ntmp_user struct
|
||||
* @vid: VLAN ID
|
||||
* @cmd: command type, NTMP_CMD_ADD or NTMP_CMD_UPDATE
|
||||
* @cfge: configuration element data
|
||||
*
|
||||
* Return: 0 on success, otherwise a negative error code
|
||||
*/
|
||||
static int ntmp_vft_set_entry(struct ntmp_user *user, u16 vid, int cmd,
|
||||
const struct vft_cfge_data *cfge)
|
||||
{
|
||||
struct netc_swcbd swcbd;
|
||||
struct vft_req_ua *req;
|
||||
struct netc_cbdr *cbdr;
|
||||
union netc_cbd cbd;
|
||||
u32 len;
|
||||
int err;
|
||||
|
||||
if (cmd != NTMP_CMD_ADD && cmd != NTMP_CMD_UPDATE)
|
||||
return -EINVAL;
|
||||
|
||||
swcbd.size = sizeof(*req);
|
||||
err = ntmp_alloc_data_mem(user->dev, &swcbd, (void **)&req);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Request data */
|
||||
ntmp_fill_crd(&req->crd, user->tbl.vft_ver, 0, NTMP_GEN_UA_CFGEU);
|
||||
req->ak.exact.vid = cpu_to_le16(vid);
|
||||
req->cfge = *cfge;
|
||||
|
||||
/* Request header */
|
||||
len = NTMP_LEN(swcbd.size, NTMP_STATUS_RESP_LEN);
|
||||
ntmp_fill_request_hdr(&cbd, swcbd.dma, len, NTMP_VFT_ID,
|
||||
cmd, NTMP_AM_EXACT_KEY);
|
||||
|
||||
ntmp_select_and_lock_cbdr(user, &cbdr);
|
||||
err = netc_xmit_ntmp_cmd(cbdr, &cbd, &swcbd);
|
||||
ntmp_unlock_cbdr(cbdr);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* ntmp_vft_add_entry - add an entry into the VLAN filter table
|
||||
* @user: target ntmp_user struct
|
||||
|
|
@ -965,9 +1010,55 @@ EXPORT_SYMBOL_GPL(ntmp_fdbt_delete_port_dynamic_entries);
|
|||
*/
|
||||
int ntmp_vft_add_entry(struct ntmp_user *user, u16 vid,
|
||||
const struct vft_cfge_data *cfge)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = ntmp_vft_set_entry(user, vid, NTMP_CMD_ADD, cfge);
|
||||
if (err)
|
||||
dev_err(user->dev,
|
||||
"Failed to add %s entry, vid: %u, err: %pe\n",
|
||||
ntmp_table_name(NTMP_VFT_ID), vid, ERR_PTR(err));
|
||||
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ntmp_vft_add_entry);
|
||||
|
||||
/**
|
||||
* ntmp_vft_update_entry - update the configuration element data of the
|
||||
* specified VLAN filter entry
|
||||
* @user: target ntmp_user struct
|
||||
* @vid: VLAN ID
|
||||
* @cfge: configuration element data
|
||||
*
|
||||
* Return: 0 on success, otherwise a negative error code
|
||||
*/
|
||||
int ntmp_vft_update_entry(struct ntmp_user *user, u16 vid,
|
||||
const struct vft_cfge_data *cfge)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = ntmp_vft_set_entry(user, vid, NTMP_CMD_UPDATE, cfge);
|
||||
if (err)
|
||||
dev_err(user->dev,
|
||||
"Failed to update %s entry, vid: %u, err: %pe\n",
|
||||
ntmp_table_name(NTMP_VFT_ID), vid, ERR_PTR(err));
|
||||
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ntmp_vft_update_entry);
|
||||
|
||||
/**
|
||||
* ntmp_vft_delete_entry - delete the VLAN filter entry based on the
|
||||
* specified VLAN ID
|
||||
* @user: target ntmp_user struct
|
||||
* @vid: VLAN ID
|
||||
*
|
||||
* Return: 0 on success, otherwise a negative error code
|
||||
*/
|
||||
int ntmp_vft_delete_entry(struct ntmp_user *user, u16 vid)
|
||||
{
|
||||
struct netc_swcbd swcbd;
|
||||
struct vft_req_ua *req;
|
||||
struct vft_req_qd *req;
|
||||
struct netc_cbdr *cbdr;
|
||||
union netc_cbd cbd;
|
||||
u32 len;
|
||||
|
|
@ -979,28 +1070,26 @@ int ntmp_vft_add_entry(struct ntmp_user *user, u16 vid,
|
|||
return err;
|
||||
|
||||
/* Request data */
|
||||
ntmp_fill_crd(&req->crd, user->tbl.vft_ver, 0,
|
||||
NTMP_GEN_UA_CFGEU);
|
||||
ntmp_fill_crd(&req->crd, user->tbl.vft_ver, 0, 0);
|
||||
req->ak.exact.vid = cpu_to_le16(vid);
|
||||
req->cfge = *cfge;
|
||||
|
||||
/* Request header */
|
||||
len = NTMP_LEN(swcbd.size, NTMP_STATUS_RESP_LEN);
|
||||
ntmp_fill_request_hdr(&cbd, swcbd.dma, len, NTMP_VFT_ID,
|
||||
NTMP_CMD_ADD, NTMP_AM_EXACT_KEY);
|
||||
NTMP_CMD_DELETE, NTMP_AM_EXACT_KEY);
|
||||
|
||||
ntmp_select_and_lock_cbdr(user, &cbdr);
|
||||
err = netc_xmit_ntmp_cmd(cbdr, &cbd, &swcbd);
|
||||
if (err)
|
||||
dev_err(user->dev,
|
||||
"Failed to add %s entry, vid: %u, err: %pe\n",
|
||||
"Failed to delete %s entry, vid: %u, err: %pe\n",
|
||||
ntmp_table_name(NTMP_VFT_ID), vid, ERR_PTR(err));
|
||||
|
||||
ntmp_unlock_cbdr(cbdr);
|
||||
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ntmp_vft_add_entry);
|
||||
EXPORT_SYMBOL_GPL(ntmp_vft_delete_entry);
|
||||
|
||||
int ntmp_bpt_update_entry(struct ntmp_user *user, u32 entry_id,
|
||||
const struct bpt_cfge_data *cfge)
|
||||
|
|
|
|||
|
|
@ -211,6 +211,12 @@ struct vft_req_ua {
|
|||
struct vft_cfge_data cfge;
|
||||
};
|
||||
|
||||
/* VLAN Filter Table Request Data Buffer Format of Query and Delete actions */
|
||||
struct vft_req_qd {
|
||||
struct ntmp_cmn_req_data crd;
|
||||
union vft_access_key ak;
|
||||
};
|
||||
|
||||
/* Buffer Pool Table Request Data Buffer Format of Update action */
|
||||
struct bpt_req_update {
|
||||
struct ntmp_req_by_eid rbe;
|
||||
|
|
|
|||
|
|
@ -268,6 +268,9 @@ int ntmp_fdbt_delete_ageing_entries(struct ntmp_user *user, u8 act_cnt);
|
|||
int ntmp_fdbt_delete_port_dynamic_entries(struct ntmp_user *user, int port);
|
||||
int ntmp_vft_add_entry(struct ntmp_user *user, u16 vid,
|
||||
const struct vft_cfge_data *cfge);
|
||||
int ntmp_vft_update_entry(struct ntmp_user *user, u16 vid,
|
||||
const struct vft_cfge_data *cfge);
|
||||
int ntmp_vft_delete_entry(struct ntmp_user *user, u16 vid);
|
||||
int ntmp_bpt_update_entry(struct ntmp_user *user, u32 entry_id,
|
||||
const struct bpt_cfge_data *cfge);
|
||||
#else
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user