Commit 16617954 authored by Ioana Ciornei's avatar Ioana Ciornei Committed by David S. Miller

dpaa2-switch: reuse dpaa2_switch_acl_entry_add() for STP frames trap

Since we added the dpaa2_switch_acl_entry_add() function in the previous
patches to hide all the details of actually adding the ACL entry by
issuing a firmware command, let's use it also for adding a CPU trap for
the STP frames.
Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4ba28c1a
......@@ -111,8 +111,8 @@ static int dpaa2_switch_flower_parse_key(struct flow_cls_offload *cls,
return 0;
}
static int dpaa2_switch_acl_entry_add(struct dpaa2_switch_acl_tbl *acl_tbl,
struct dpaa2_switch_acl_entry *entry)
int dpaa2_switch_acl_entry_add(struct dpaa2_switch_acl_tbl *acl_tbl,
struct dpaa2_switch_acl_entry *entry)
{
struct dpsw_acl_entry_cfg *acl_entry_cfg = &entry->cfg;
struct ethsw_core *ethsw = acl_tbl->ethsw;
......
......@@ -2942,54 +2942,17 @@ static int dpaa2_switch_init(struct fsl_mc_device *sw_dev)
static int dpaa2_switch_port_trap_mac_addr(struct ethsw_port_priv *port_priv,
const char *mac)
{
struct net_device *netdev = port_priv->netdev;
struct dpsw_acl_entry_cfg acl_entry_cfg;
struct dpsw_acl_fields *acl_h;
struct dpsw_acl_fields *acl_m;
struct dpsw_acl_key acl_key;
struct device *dev;
u8 *cmd_buff;
int err;
dev = port_priv->netdev->dev.parent;
acl_h = &acl_key.match;
acl_m = &acl_key.mask;
memset(&acl_entry_cfg, 0, sizeof(acl_entry_cfg));
memset(&acl_key, 0, sizeof(acl_key));
struct dpaa2_switch_acl_entry acl_entry = {0};
/* Match on the destination MAC address */
ether_addr_copy(acl_h->l2_dest_mac, mac);
eth_broadcast_addr(acl_m->l2_dest_mac);
cmd_buff = kzalloc(DPAA2_ETHSW_PORT_ACL_CMD_BUF_SIZE, GFP_KERNEL);
if (!cmd_buff)
return -ENOMEM;
dpsw_acl_prepare_entry_cfg(&acl_key, cmd_buff);
ether_addr_copy(acl_entry.key.match.l2_dest_mac, mac);
eth_broadcast_addr(acl_entry.key.mask.l2_dest_mac);
memset(&acl_entry_cfg, 0, sizeof(acl_entry_cfg));
acl_entry_cfg.precedence = 0;
acl_entry_cfg.result.action = DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF;
acl_entry_cfg.key_iova = dma_map_single(dev, cmd_buff,
DPAA2_ETHSW_PORT_ACL_CMD_BUF_SIZE,
DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(dev, acl_entry_cfg.key_iova))) {
netdev_err(netdev, "DMA mapping failed\n");
return -EFAULT;
}
/* Trap to CPU */
acl_entry.cfg.precedence = 0;
acl_entry.cfg.result.action = DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF;
err = dpsw_acl_add_entry(port_priv->ethsw_data->mc_io, 0,
port_priv->ethsw_data->dpsw_handle,
port_priv->acl_tbl->id, &acl_entry_cfg);
dma_unmap_single(dev, acl_entry_cfg.key_iova, sizeof(cmd_buff),
DMA_TO_DEVICE);
if (err) {
netdev_err(netdev, "dpsw_acl_add_entry() failed %d\n", err);
return err;
}
return 0;
return dpaa2_switch_acl_entry_add(port_priv->acl_tbl, &acl_entry);
}
static int dpaa2_switch_port_init(struct ethsw_port_priv *port_priv, u16 port)
......
......@@ -240,4 +240,7 @@ int dpaa2_switch_cls_matchall_replace(struct dpaa2_switch_acl_tbl *acl_tbl,
int dpaa2_switch_cls_matchall_destroy(struct dpaa2_switch_acl_tbl *acl_tbl,
struct tc_cls_matchall_offload *cls);
int dpaa2_switch_acl_entry_add(struct dpaa2_switch_acl_tbl *acl_tbl,
struct dpaa2_switch_acl_entry *entry);
#endif /* __ETHSW_H */
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