2018-12-20 18:14:50 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2018-03-14 10:55:54 -05:00
|
|
|
/*
|
|
|
|
* DPAA2 Ethernet Switch declarations
|
|
|
|
*
|
|
|
|
* Copyright 2014-2016 Freescale Semiconductor Inc.
|
2021-03-10 14:14:41 +02:00
|
|
|
* Copyright 2017-2021 NXP
|
2018-03-14 10:55:54 -05:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ETHSW_H
|
|
|
|
#define __ETHSW_H
|
|
|
|
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/rtnetlink.h>
|
|
|
|
#include <linux/if_vlan.h>
|
|
|
|
#include <uapi/linux/if_bridge.h>
|
|
|
|
#include <net/switchdev.h>
|
|
|
|
#include <linux/if_bridge.h>
|
2021-03-10 14:14:42 +02:00
|
|
|
#include <linux/fsl/mc.h>
|
2021-04-13 16:24:47 +03:00
|
|
|
#include <net/pkt_cls.h>
|
2021-03-10 14:14:42 +02:00
|
|
|
#include <soc/fsl/dpaa2-io.h>
|
2018-03-14 10:55:54 -05:00
|
|
|
|
2021-08-03 19:57:43 +03:00
|
|
|
#include "dpaa2-mac.h"
|
2018-03-14 10:55:54 -05:00
|
|
|
#include "dpsw.h"
|
|
|
|
|
|
|
|
/* Number of IRQs supported */
|
|
|
|
#define DPSW_IRQ_NUM 2
|
|
|
|
|
2019-07-05 17:27:16 +03:00
|
|
|
/* Port is member of VLAN */
|
2018-03-14 10:55:54 -05:00
|
|
|
#define ETHSW_VLAN_MEMBER 1
|
2019-07-05 17:27:16 +03:00
|
|
|
/* VLAN to be treated as untagged on egress */
|
2018-03-14 10:55:54 -05:00
|
|
|
#define ETHSW_VLAN_UNTAGGED 2
|
2019-07-05 17:27:16 +03:00
|
|
|
/* Untagged frames will be assigned to this VLAN */
|
2018-03-14 10:55:54 -05:00
|
|
|
#define ETHSW_VLAN_PVID 4
|
2019-07-05 17:27:16 +03:00
|
|
|
/* VLAN configured on the switch */
|
2018-03-14 10:55:54 -05:00
|
|
|
#define ETHSW_VLAN_GLOBAL 8
|
|
|
|
|
|
|
|
/* Maximum Frame Length supported by HW (currently 10k) */
|
|
|
|
#define DPAA2_MFL (10 * 1024)
|
|
|
|
#define ETHSW_MAX_FRAME_LENGTH (DPAA2_MFL - VLAN_ETH_HLEN - ETH_FCS_LEN)
|
|
|
|
#define ETHSW_L2_MAX_FRM(mtu) ((mtu) + VLAN_ETH_HLEN + ETH_FCS_LEN)
|
|
|
|
|
2020-07-14 16:34:31 +03:00
|
|
|
#define ETHSW_FEATURE_MAC_ADDR BIT(0)
|
|
|
|
|
2021-03-10 14:14:41 +02:00
|
|
|
/* Number of receive queues (one RX and one TX_CONF) */
|
|
|
|
#define DPAA2_SWITCH_RX_NUM_FQS 2
|
|
|
|
|
2021-03-10 14:14:42 +02:00
|
|
|
/* Hardware requires alignment for ingress/egress buffer addresses */
|
|
|
|
#define DPAA2_SWITCH_RX_BUF_RAW_SIZE PAGE_SIZE
|
|
|
|
#define DPAA2_SWITCH_RX_BUF_TAILROOM \
|
|
|
|
SKB_DATA_ALIGN(sizeof(struct skb_shared_info))
|
|
|
|
#define DPAA2_SWITCH_RX_BUF_SIZE \
|
|
|
|
(DPAA2_SWITCH_RX_BUF_RAW_SIZE - DPAA2_SWITCH_RX_BUF_TAILROOM)
|
|
|
|
|
|
|
|
#define DPAA2_SWITCH_STORE_SIZE 16
|
|
|
|
|
2021-03-10 14:14:44 +02:00
|
|
|
/* Buffer management */
|
|
|
|
#define BUFS_PER_CMD 7
|
|
|
|
#define DPAA2_ETHSW_NUM_BUFS (1024 * BUFS_PER_CMD)
|
|
|
|
#define DPAA2_ETHSW_REFILL_THRESH (DPAA2_ETHSW_NUM_BUFS * 5 / 6)
|
|
|
|
|
|
|
|
/* Number of times to retry DPIO portal operations while waiting
|
|
|
|
* for portal to finish executing current command and become
|
|
|
|
* available. We want to avoid being stuck in a while loop in case
|
|
|
|
* hardware becomes unresponsive, but not give up too easily if
|
|
|
|
* the portal really is busy for valid reasons
|
|
|
|
*/
|
|
|
|
#define DPAA2_SWITCH_SWP_BUSY_RETRIES 1000
|
|
|
|
|
2021-03-10 14:14:45 +02:00
|
|
|
/* Hardware annotation buffer size */
|
|
|
|
#define DPAA2_SWITCH_HWA_SIZE 64
|
|
|
|
/* Software annotation buffer size */
|
|
|
|
#define DPAA2_SWITCH_SWA_SIZE 64
|
|
|
|
|
|
|
|
#define DPAA2_SWITCH_TX_BUF_ALIGN 64
|
|
|
|
|
|
|
|
#define DPAA2_SWITCH_TX_DATA_OFFSET \
|
|
|
|
(DPAA2_SWITCH_HWA_SIZE + DPAA2_SWITCH_SWA_SIZE)
|
|
|
|
|
|
|
|
#define DPAA2_SWITCH_NEEDED_HEADROOM \
|
|
|
|
(DPAA2_SWITCH_TX_DATA_OFFSET + DPAA2_SWITCH_TX_BUF_ALIGN)
|
|
|
|
|
2021-03-30 17:54:16 +03:00
|
|
|
#define DPAA2_ETHSW_PORT_MAX_ACL_ENTRIES 16
|
2021-04-13 16:24:46 +03:00
|
|
|
#define DPAA2_ETHSW_PORT_DEFAULT_TRAPS 1
|
|
|
|
|
2021-03-30 17:54:18 +03:00
|
|
|
#define DPAA2_ETHSW_PORT_ACL_CMD_BUF_SIZE 256
|
2021-03-30 17:54:16 +03:00
|
|
|
|
2020-10-09 18:29:59 +03:00
|
|
|
extern const struct ethtool_ops dpaa2_switch_port_ethtool_ops;
|
2018-03-14 10:55:55 -05:00
|
|
|
|
2018-03-14 10:55:54 -05:00
|
|
|
struct ethsw_core;
|
|
|
|
|
2021-03-10 14:14:41 +02:00
|
|
|
struct dpaa2_switch_fq {
|
|
|
|
struct ethsw_core *ethsw;
|
|
|
|
enum dpsw_queue_type type;
|
2021-03-10 14:14:42 +02:00
|
|
|
struct dpaa2_io_store *store;
|
2021-03-10 14:14:43 +02:00
|
|
|
struct dpaa2_io_notification_ctx nctx;
|
2021-03-10 14:14:44 +02:00
|
|
|
struct napi_struct napi;
|
2021-03-10 14:14:41 +02:00
|
|
|
u32 fqid;
|
|
|
|
};
|
|
|
|
|
staging: dpaa2-switch: properly setup switching domains
Until now, the DPAA2 switch was not capable to properly setup its
switching domains depending on the existence, or lack thereof, of a
upper bridge device. This meant that all switch ports of a DPSW object
were switching by default even though they were not under the same
bridge device.
Another issue was the inability to actually add the CPU in the flooding
domains (broadcast, unknown unicast etc) of a particular switch port.
This meant that a simple ping on a switch interface was not possible
since no broadcast ARP frame would actually reach the CPU queues.
This patch tries to fix exactly these problems by:
* Creating and managing a FDB table for each flooding domain. This means
that when a switch interface is not bridged it will use its own FDB
table. While in bridged mode all DPAA2 switch interfaces under the
same upper will use the same FDB table, thus leverage the same FDB
entries.
* Adding a new MC firmware command - dpsw_set_egress_flood() - through
which the driver can setup the flooding domains as needed. For
example, when the switch interface is standalone, thus not in a
bridge with any other DPAA2 switch port, it will setup its broadcast
and unknown unicast flooding domains to only include the control
interface (the queues that reach the CPU and the driver can dequeue
from). This flooding domain changes when the interface joins a bridge
and is configured to include, beside the control interface, all other
DPAA2 switch interfaces.
We impose a minimum limit of FDB tables available equal to the number of
switch interfaces so that we guarantee that, in the maximal
configuration - all interfaces are standalone, each switch port will
have a private FDB table. At the same time, we only probe DPSW objects
that have the flooding and broadcast replicators configured to be per
FDB (DPSW_*_PER_FDB). Without this, the dpaa2-switch driver would not
be able to configure multiple switching domains.
At probe time, a FDB table will be allocated for each port. At a bridge
join event, the switch port will either continue to use the current FDB
table (if it's the first dpaa2-switch port to join that bridge) or will
switch to use the FDB table associated with the port that it's already
under the bridge. If a FDB switch is necessary, the private FDB table
which was previously used will be returned to the pool of unused FDBs.
Upon a bridge leave, the switch port needs a private FDB table thus it
will search and get the first unused FDB table. This way, all the other
ports remaining under the bridge will continue to use the same FDB
table.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10 14:14:47 +02:00
|
|
|
struct dpaa2_switch_fdb {
|
|
|
|
struct net_device *bridge_dev;
|
|
|
|
u16 fdb_id;
|
|
|
|
bool in_use;
|
|
|
|
};
|
|
|
|
|
2021-04-13 16:24:46 +03:00
|
|
|
struct dpaa2_switch_acl_entry {
|
|
|
|
struct list_head list;
|
|
|
|
u16 prio;
|
|
|
|
unsigned long cookie;
|
|
|
|
|
|
|
|
struct dpsw_acl_entry_cfg cfg;
|
|
|
|
struct dpsw_acl_key key;
|
|
|
|
};
|
|
|
|
|
2021-07-29 20:18:58 +03:00
|
|
|
struct dpaa2_switch_mirror_entry {
|
|
|
|
struct list_head list;
|
|
|
|
struct dpsw_reflection_cfg cfg;
|
|
|
|
unsigned long cookie;
|
|
|
|
u16 if_id;
|
|
|
|
};
|
|
|
|
|
2021-07-29 20:18:54 +03:00
|
|
|
struct dpaa2_switch_filter_block {
|
2021-04-13 16:24:46 +03:00
|
|
|
struct ethsw_core *ethsw;
|
|
|
|
u64 ports;
|
2021-04-13 16:24:44 +03:00
|
|
|
bool in_use;
|
2021-07-29 20:18:54 +03:00
|
|
|
|
|
|
|
struct list_head acl_entries;
|
|
|
|
u16 acl_id;
|
|
|
|
u8 num_acl_rules;
|
2021-07-29 20:18:58 +03:00
|
|
|
|
|
|
|
struct list_head mirror_entries;
|
2021-04-13 16:24:44 +03:00
|
|
|
};
|
|
|
|
|
2021-04-13 16:24:46 +03:00
|
|
|
static inline bool
|
2021-07-29 20:18:54 +03:00
|
|
|
dpaa2_switch_acl_tbl_is_full(struct dpaa2_switch_filter_block *filter_block)
|
2021-04-13 16:24:46 +03:00
|
|
|
{
|
2021-07-29 20:18:54 +03:00
|
|
|
if ((filter_block->num_acl_rules + DPAA2_ETHSW_PORT_DEFAULT_TRAPS) >=
|
2021-04-13 16:24:46 +03:00
|
|
|
DPAA2_ETHSW_PORT_MAX_ACL_ENTRIES)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-03-14 10:55:54 -05:00
|
|
|
/* Per port private data */
|
|
|
|
struct ethsw_port_priv {
|
|
|
|
struct net_device *netdev;
|
|
|
|
u16 idx;
|
|
|
|
struct ethsw_core *ethsw_data;
|
|
|
|
u8 link_state;
|
|
|
|
u8 stp_state;
|
|
|
|
|
|
|
|
u8 vlans[VLAN_VID_MASK + 1];
|
|
|
|
u16 pvid;
|
2021-03-10 14:14:45 +02:00
|
|
|
u16 tx_qdid;
|
staging: dpaa2-switch: properly setup switching domains
Until now, the DPAA2 switch was not capable to properly setup its
switching domains depending on the existence, or lack thereof, of a
upper bridge device. This meant that all switch ports of a DPSW object
were switching by default even though they were not under the same
bridge device.
Another issue was the inability to actually add the CPU in the flooding
domains (broadcast, unknown unicast etc) of a particular switch port.
This meant that a simple ping on a switch interface was not possible
since no broadcast ARP frame would actually reach the CPU queues.
This patch tries to fix exactly these problems by:
* Creating and managing a FDB table for each flooding domain. This means
that when a switch interface is not bridged it will use its own FDB
table. While in bridged mode all DPAA2 switch interfaces under the
same upper will use the same FDB table, thus leverage the same FDB
entries.
* Adding a new MC firmware command - dpsw_set_egress_flood() - through
which the driver can setup the flooding domains as needed. For
example, when the switch interface is standalone, thus not in a
bridge with any other DPAA2 switch port, it will setup its broadcast
and unknown unicast flooding domains to only include the control
interface (the queues that reach the CPU and the driver can dequeue
from). This flooding domain changes when the interface joins a bridge
and is configured to include, beside the control interface, all other
DPAA2 switch interfaces.
We impose a minimum limit of FDB tables available equal to the number of
switch interfaces so that we guarantee that, in the maximal
configuration - all interfaces are standalone, each switch port will
have a private FDB table. At the same time, we only probe DPSW objects
that have the flooding and broadcast replicators configured to be per
FDB (DPSW_*_PER_FDB). Without this, the dpaa2-switch driver would not
be able to configure multiple switching domains.
At probe time, a FDB table will be allocated for each port. At a bridge
join event, the switch port will either continue to use the current FDB
table (if it's the first dpaa2-switch port to join that bridge) or will
switch to use the FDB table associated with the port that it's already
under the bridge. If a FDB switch is necessary, the private FDB table
which was previously used will be returned to the pool of unused FDBs.
Upon a bridge leave, the switch port needs a private FDB table thus it
will search and get the first unused FDB table. This way, all the other
ports remaining under the bridge will continue to use the same FDB
table.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10 14:14:47 +02:00
|
|
|
|
|
|
|
struct dpaa2_switch_fdb *fdb;
|
2021-03-22 22:58:57 +02:00
|
|
|
bool bcast_flood;
|
2021-03-22 22:58:58 +02:00
|
|
|
bool ucast_flood;
|
2021-03-30 17:54:17 +03:00
|
|
|
bool learn_ena;
|
2021-03-30 17:54:16 +03:00
|
|
|
|
2021-07-29 20:18:54 +03:00
|
|
|
struct dpaa2_switch_filter_block *filter_block;
|
2021-08-03 19:57:43 +03:00
|
|
|
struct dpaa2_mac *mac;
|
2022-11-29 16:12:20 +02:00
|
|
|
/* Protects against changes to port_priv->mac */
|
|
|
|
struct mutex mac_lock;
|
2018-03-14 10:55:54 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Switch data */
|
|
|
|
struct ethsw_core {
|
|
|
|
struct device *dev;
|
|
|
|
struct fsl_mc_io *mc_io;
|
|
|
|
u16 dpsw_handle;
|
|
|
|
struct dpsw_attr sw_attr;
|
2020-07-14 16:34:30 +03:00
|
|
|
u16 major, minor;
|
2020-07-14 16:34:31 +03:00
|
|
|
unsigned long features;
|
2018-03-14 10:55:54 -05:00
|
|
|
int dev_id;
|
|
|
|
struct ethsw_port_priv **ports;
|
2021-03-10 14:14:44 +02:00
|
|
|
struct iommu_domain *iommu_domain;
|
2018-03-14 10:55:54 -05:00
|
|
|
|
|
|
|
u8 vlans[VLAN_VID_MASK + 1];
|
2019-11-11 18:50:55 +02:00
|
|
|
|
2019-11-11 18:50:58 +02:00
|
|
|
struct workqueue_struct *workqueue;
|
2021-03-10 14:14:41 +02:00
|
|
|
|
|
|
|
struct dpaa2_switch_fq fq[DPAA2_SWITCH_RX_NUM_FQS];
|
2021-03-10 14:14:42 +02:00
|
|
|
struct fsl_mc_device *dpbp_dev;
|
2021-03-10 14:14:44 +02:00
|
|
|
int buf_count;
|
2021-03-10 14:14:42 +02:00
|
|
|
u16 bpid;
|
2021-03-10 14:14:44 +02:00
|
|
|
int napi_users;
|
staging: dpaa2-switch: properly setup switching domains
Until now, the DPAA2 switch was not capable to properly setup its
switching domains depending on the existence, or lack thereof, of a
upper bridge device. This meant that all switch ports of a DPSW object
were switching by default even though they were not under the same
bridge device.
Another issue was the inability to actually add the CPU in the flooding
domains (broadcast, unknown unicast etc) of a particular switch port.
This meant that a simple ping on a switch interface was not possible
since no broadcast ARP frame would actually reach the CPU queues.
This patch tries to fix exactly these problems by:
* Creating and managing a FDB table for each flooding domain. This means
that when a switch interface is not bridged it will use its own FDB
table. While in bridged mode all DPAA2 switch interfaces under the
same upper will use the same FDB table, thus leverage the same FDB
entries.
* Adding a new MC firmware command - dpsw_set_egress_flood() - through
which the driver can setup the flooding domains as needed. For
example, when the switch interface is standalone, thus not in a
bridge with any other DPAA2 switch port, it will setup its broadcast
and unknown unicast flooding domains to only include the control
interface (the queues that reach the CPU and the driver can dequeue
from). This flooding domain changes when the interface joins a bridge
and is configured to include, beside the control interface, all other
DPAA2 switch interfaces.
We impose a minimum limit of FDB tables available equal to the number of
switch interfaces so that we guarantee that, in the maximal
configuration - all interfaces are standalone, each switch port will
have a private FDB table. At the same time, we only probe DPSW objects
that have the flooding and broadcast replicators configured to be per
FDB (DPSW_*_PER_FDB). Without this, the dpaa2-switch driver would not
be able to configure multiple switching domains.
At probe time, a FDB table will be allocated for each port. At a bridge
join event, the switch port will either continue to use the current FDB
table (if it's the first dpaa2-switch port to join that bridge) or will
switch to use the FDB table associated with the port that it's already
under the bridge. If a FDB switch is necessary, the private FDB table
which was previously used will be returned to the pool of unused FDBs.
Upon a bridge leave, the switch port needs a private FDB table thus it
will search and get the first unused FDB table. This way, all the other
ports remaining under the bridge will continue to use the same FDB
table.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10 14:14:47 +02:00
|
|
|
|
|
|
|
struct dpaa2_switch_fdb *fdbs;
|
2021-07-29 20:18:54 +03:00
|
|
|
struct dpaa2_switch_filter_block *filter_blocks;
|
2021-07-29 20:18:58 +03:00
|
|
|
u16 mirror_port;
|
2018-03-14 10:55:54 -05:00
|
|
|
};
|
|
|
|
|
2021-04-13 16:24:46 +03:00
|
|
|
static inline int dpaa2_switch_get_index(struct ethsw_core *ethsw,
|
|
|
|
struct net_device *netdev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ethsw->sw_attr.num_ifs; i++)
|
|
|
|
if (ethsw->ports[i]->netdev == netdev)
|
|
|
|
return ethsw->ports[i]->idx;
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2021-03-10 14:14:41 +02:00
|
|
|
static inline bool dpaa2_switch_supports_cpu_traffic(struct ethsw_core *ethsw)
|
|
|
|
{
|
|
|
|
if (ethsw->sw_attr.options & DPSW_OPT_CTRL_IF_DIS) {
|
|
|
|
dev_err(ethsw->dev, "Control Interface is disabled, cannot probe\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
staging: dpaa2-switch: properly setup switching domains
Until now, the DPAA2 switch was not capable to properly setup its
switching domains depending on the existence, or lack thereof, of a
upper bridge device. This meant that all switch ports of a DPSW object
were switching by default even though they were not under the same
bridge device.
Another issue was the inability to actually add the CPU in the flooding
domains (broadcast, unknown unicast etc) of a particular switch port.
This meant that a simple ping on a switch interface was not possible
since no broadcast ARP frame would actually reach the CPU queues.
This patch tries to fix exactly these problems by:
* Creating and managing a FDB table for each flooding domain. This means
that when a switch interface is not bridged it will use its own FDB
table. While in bridged mode all DPAA2 switch interfaces under the
same upper will use the same FDB table, thus leverage the same FDB
entries.
* Adding a new MC firmware command - dpsw_set_egress_flood() - through
which the driver can setup the flooding domains as needed. For
example, when the switch interface is standalone, thus not in a
bridge with any other DPAA2 switch port, it will setup its broadcast
and unknown unicast flooding domains to only include the control
interface (the queues that reach the CPU and the driver can dequeue
from). This flooding domain changes when the interface joins a bridge
and is configured to include, beside the control interface, all other
DPAA2 switch interfaces.
We impose a minimum limit of FDB tables available equal to the number of
switch interfaces so that we guarantee that, in the maximal
configuration - all interfaces are standalone, each switch port will
have a private FDB table. At the same time, we only probe DPSW objects
that have the flooding and broadcast replicators configured to be per
FDB (DPSW_*_PER_FDB). Without this, the dpaa2-switch driver would not
be able to configure multiple switching domains.
At probe time, a FDB table will be allocated for each port. At a bridge
join event, the switch port will either continue to use the current FDB
table (if it's the first dpaa2-switch port to join that bridge) or will
switch to use the FDB table associated with the port that it's already
under the bridge. If a FDB switch is necessary, the private FDB table
which was previously used will be returned to the pool of unused FDBs.
Upon a bridge leave, the switch port needs a private FDB table thus it
will search and get the first unused FDB table. This way, all the other
ports remaining under the bridge will continue to use the same FDB
table.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10 14:14:47 +02:00
|
|
|
if (ethsw->sw_attr.flooding_cfg != DPSW_FLOODING_PER_FDB) {
|
|
|
|
dev_err(ethsw->dev, "Flooding domain is not per FDB, cannot probe\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ethsw->sw_attr.broadcast_cfg != DPSW_BROADCAST_PER_FDB) {
|
|
|
|
dev_err(ethsw->dev, "Broadcast domain is not per FDB, cannot probe\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ethsw->sw_attr.max_fdbs < ethsw->sw_attr.num_ifs) {
|
|
|
|
dev_err(ethsw->dev, "The number of FDBs is lower than the number of ports, cannot probe\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-03-10 14:14:41 +02:00
|
|
|
return true;
|
|
|
|
}
|
staging: dpaa2-switch: properly setup switching domains
Until now, the DPAA2 switch was not capable to properly setup its
switching domains depending on the existence, or lack thereof, of a
upper bridge device. This meant that all switch ports of a DPSW object
were switching by default even though they were not under the same
bridge device.
Another issue was the inability to actually add the CPU in the flooding
domains (broadcast, unknown unicast etc) of a particular switch port.
This meant that a simple ping on a switch interface was not possible
since no broadcast ARP frame would actually reach the CPU queues.
This patch tries to fix exactly these problems by:
* Creating and managing a FDB table for each flooding domain. This means
that when a switch interface is not bridged it will use its own FDB
table. While in bridged mode all DPAA2 switch interfaces under the
same upper will use the same FDB table, thus leverage the same FDB
entries.
* Adding a new MC firmware command - dpsw_set_egress_flood() - through
which the driver can setup the flooding domains as needed. For
example, when the switch interface is standalone, thus not in a
bridge with any other DPAA2 switch port, it will setup its broadcast
and unknown unicast flooding domains to only include the control
interface (the queues that reach the CPU and the driver can dequeue
from). This flooding domain changes when the interface joins a bridge
and is configured to include, beside the control interface, all other
DPAA2 switch interfaces.
We impose a minimum limit of FDB tables available equal to the number of
switch interfaces so that we guarantee that, in the maximal
configuration - all interfaces are standalone, each switch port will
have a private FDB table. At the same time, we only probe DPSW objects
that have the flooding and broadcast replicators configured to be per
FDB (DPSW_*_PER_FDB). Without this, the dpaa2-switch driver would not
be able to configure multiple switching domains.
At probe time, a FDB table will be allocated for each port. At a bridge
join event, the switch port will either continue to use the current FDB
table (if it's the first dpaa2-switch port to join that bridge) or will
switch to use the FDB table associated with the port that it's already
under the bridge. If a FDB switch is necessary, the private FDB table
which was previously used will be returned to the pool of unused FDBs.
Upon a bridge leave, the switch port needs a private FDB table thus it
will search and get the first unused FDB table. This way, all the other
ports remaining under the bridge will continue to use the same FDB
table.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10 14:14:47 +02:00
|
|
|
|
2021-08-03 19:57:43 +03:00
|
|
|
static inline bool
|
|
|
|
dpaa2_switch_port_is_type_phy(struct ethsw_port_priv *port_priv)
|
|
|
|
{
|
2022-11-29 16:12:11 +02:00
|
|
|
return dpaa2_mac_is_type_phy(port_priv->mac);
|
2021-08-03 19:57:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool dpaa2_switch_port_has_mac(struct ethsw_port_priv *port_priv)
|
|
|
|
{
|
|
|
|
return port_priv->mac ? true : false;
|
|
|
|
}
|
|
|
|
|
2021-03-10 14:14:48 +02:00
|
|
|
bool dpaa2_switch_port_dev_check(const struct net_device *netdev);
|
staging: dpaa2-switch: properly setup switching domains
Until now, the DPAA2 switch was not capable to properly setup its
switching domains depending on the existence, or lack thereof, of a
upper bridge device. This meant that all switch ports of a DPSW object
were switching by default even though they were not under the same
bridge device.
Another issue was the inability to actually add the CPU in the flooding
domains (broadcast, unknown unicast etc) of a particular switch port.
This meant that a simple ping on a switch interface was not possible
since no broadcast ARP frame would actually reach the CPU queues.
This patch tries to fix exactly these problems by:
* Creating and managing a FDB table for each flooding domain. This means
that when a switch interface is not bridged it will use its own FDB
table. While in bridged mode all DPAA2 switch interfaces under the
same upper will use the same FDB table, thus leverage the same FDB
entries.
* Adding a new MC firmware command - dpsw_set_egress_flood() - through
which the driver can setup the flooding domains as needed. For
example, when the switch interface is standalone, thus not in a
bridge with any other DPAA2 switch port, it will setup its broadcast
and unknown unicast flooding domains to only include the control
interface (the queues that reach the CPU and the driver can dequeue
from). This flooding domain changes when the interface joins a bridge
and is configured to include, beside the control interface, all other
DPAA2 switch interfaces.
We impose a minimum limit of FDB tables available equal to the number of
switch interfaces so that we guarantee that, in the maximal
configuration - all interfaces are standalone, each switch port will
have a private FDB table. At the same time, we only probe DPSW objects
that have the flooding and broadcast replicators configured to be per
FDB (DPSW_*_PER_FDB). Without this, the dpaa2-switch driver would not
be able to configure multiple switching domains.
At probe time, a FDB table will be allocated for each port. At a bridge
join event, the switch port will either continue to use the current FDB
table (if it's the first dpaa2-switch port to join that bridge) or will
switch to use the FDB table associated with the port that it's already
under the bridge. If a FDB switch is necessary, the private FDB table
which was previously used will be returned to the pool of unused FDBs.
Upon a bridge leave, the switch port needs a private FDB table thus it
will search and get the first unused FDB table. This way, all the other
ports remaining under the bridge will continue to use the same FDB
table.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-10 14:14:47 +02:00
|
|
|
|
2021-03-10 14:14:49 +02:00
|
|
|
int dpaa2_switch_port_vlans_add(struct net_device *netdev,
|
|
|
|
const struct switchdev_obj_port_vlan *vlan);
|
|
|
|
|
|
|
|
int dpaa2_switch_port_vlans_del(struct net_device *netdev,
|
|
|
|
const struct switchdev_obj_port_vlan *vlan);
|
|
|
|
|
2021-03-10 14:14:50 +02:00
|
|
|
typedef int dpaa2_switch_fdb_cb_t(struct ethsw_port_priv *port_priv,
|
|
|
|
struct fdb_dump_entry *fdb_entry,
|
|
|
|
void *data);
|
2021-04-13 16:24:46 +03:00
|
|
|
|
|
|
|
/* TC offload */
|
|
|
|
|
2021-07-29 20:18:54 +03:00
|
|
|
int dpaa2_switch_cls_flower_replace(struct dpaa2_switch_filter_block *block,
|
2021-04-13 16:24:46 +03:00
|
|
|
struct flow_cls_offload *cls);
|
|
|
|
|
2021-07-29 20:18:54 +03:00
|
|
|
int dpaa2_switch_cls_flower_destroy(struct dpaa2_switch_filter_block *block,
|
2021-04-13 16:24:46 +03:00
|
|
|
struct flow_cls_offload *cls);
|
2021-04-13 16:24:47 +03:00
|
|
|
|
2021-07-29 20:18:54 +03:00
|
|
|
int dpaa2_switch_cls_matchall_replace(struct dpaa2_switch_filter_block *block,
|
2021-04-13 16:24:47 +03:00
|
|
|
struct tc_cls_matchall_offload *cls);
|
|
|
|
|
2021-07-29 20:18:54 +03:00
|
|
|
int dpaa2_switch_cls_matchall_destroy(struct dpaa2_switch_filter_block *block,
|
2021-04-13 16:24:47 +03:00
|
|
|
struct tc_cls_matchall_offload *cls);
|
2021-04-13 16:24:48 +03:00
|
|
|
|
2021-07-29 20:18:54 +03:00
|
|
|
int dpaa2_switch_acl_entry_add(struct dpaa2_switch_filter_block *block,
|
2021-04-13 16:24:48 +03:00
|
|
|
struct dpaa2_switch_acl_entry *entry);
|
2021-07-29 20:19:00 +03:00
|
|
|
|
|
|
|
int dpaa2_switch_block_offload_mirror(struct dpaa2_switch_filter_block *block,
|
|
|
|
struct ethsw_port_priv *port_priv);
|
|
|
|
|
|
|
|
int dpaa2_switch_block_unoffload_mirror(struct dpaa2_switch_filter_block *block,
|
|
|
|
struct ethsw_port_priv *port_priv);
|
2018-03-14 10:55:54 -05:00
|
|
|
#endif /* __ETHSW_H */
|