Commit 992e5cc7 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: dsa: tag_8021q: make dsa_8021q_{rx,tx}_vid take dp as argument

Pass a single argument to dsa_8021q_rx_vid and dsa_8021q_tx_vid that
contains the necessary information from the two arguments that are
currently provided: the switch and the port number.

Also rename those functions so that they have a dsa_port_* prefix, since
they operate on a struct dsa_port *.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5068887a
...@@ -394,7 +394,8 @@ static int sja1105_init_virtual_links(struct sja1105_private *priv, ...@@ -394,7 +394,8 @@ static int sja1105_init_virtual_links(struct sja1105_private *priv,
vl_lookup[k].vlanid = rule->key.vl.vid; vl_lookup[k].vlanid = rule->key.vl.vid;
vl_lookup[k].vlanprior = rule->key.vl.pcp; vl_lookup[k].vlanprior = rule->key.vl.pcp;
} else { } else {
u16 vid = dsa_8021q_rx_vid(priv->ds, port); struct dsa_port *dp = dsa_to_port(priv->ds, port);
u16 vid = dsa_tag_8021q_rx_vid(dp);
vl_lookup[k].vlanid = vid; vl_lookup[k].vlanid = vid;
vl_lookup[k].vlanprior = 0; vl_lookup[k].vlanprior = 0;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/types.h> #include <linux/types.h>
struct dsa_switch; struct dsa_switch;
struct dsa_port;
struct sk_buff; struct sk_buff;
struct net_device; struct net_device;
...@@ -45,9 +46,9 @@ void dsa_tag_8021q_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port, ...@@ -45,9 +46,9 @@ void dsa_tag_8021q_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port,
u16 dsa_8021q_bridge_tx_fwd_offload_vid(int bridge_num); u16 dsa_8021q_bridge_tx_fwd_offload_vid(int bridge_num);
u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port); u16 dsa_tag_8021q_tx_vid(const struct dsa_port *dp);
u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port); u16 dsa_tag_8021q_rx_vid(const struct dsa_port *dp);
int dsa_8021q_rx_switch_id(u16 vid); int dsa_8021q_rx_switch_id(u16 vid);
......
...@@ -77,22 +77,22 @@ EXPORT_SYMBOL_GPL(dsa_8021q_bridge_tx_fwd_offload_vid); ...@@ -77,22 +77,22 @@ EXPORT_SYMBOL_GPL(dsa_8021q_bridge_tx_fwd_offload_vid);
/* Returns the VID to be inserted into the frame from xmit for switch steering /* Returns the VID to be inserted into the frame from xmit for switch steering
* instructions on egress. Encodes switch ID and port ID. * instructions on egress. Encodes switch ID and port ID.
*/ */
u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port) u16 dsa_tag_8021q_tx_vid(const struct dsa_port *dp)
{ {
return DSA_8021Q_DIR_TX | DSA_8021Q_SWITCH_ID(ds->index) | return DSA_8021Q_DIR_TX | DSA_8021Q_SWITCH_ID(dp->ds->index) |
DSA_8021Q_PORT(port); DSA_8021Q_PORT(dp->index);
} }
EXPORT_SYMBOL_GPL(dsa_8021q_tx_vid); EXPORT_SYMBOL_GPL(dsa_tag_8021q_tx_vid);
/* Returns the VID that will be installed as pvid for this switch port, sent as /* Returns the VID that will be installed as pvid for this switch port, sent as
* tagged egress towards the CPU port and decoded by the rcv function. * tagged egress towards the CPU port and decoded by the rcv function.
*/ */
u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port) u16 dsa_tag_8021q_rx_vid(const struct dsa_port *dp)
{ {
return DSA_8021Q_DIR_RX | DSA_8021Q_SWITCH_ID(ds->index) | return DSA_8021Q_DIR_RX | DSA_8021Q_SWITCH_ID(dp->ds->index) |
DSA_8021Q_PORT(port); DSA_8021Q_PORT(dp->index);
} }
EXPORT_SYMBOL_GPL(dsa_8021q_rx_vid); EXPORT_SYMBOL_GPL(dsa_tag_8021q_rx_vid);
/* Returns the decoded switch ID from the RX VID. */ /* Returns the decoded switch ID from the RX VID. */
int dsa_8021q_rx_switch_id(u16 vid) int dsa_8021q_rx_switch_id(u16 vid)
...@@ -354,10 +354,10 @@ int dsa_tag_8021q_bridge_join(struct dsa_switch *ds, ...@@ -354,10 +354,10 @@ int dsa_tag_8021q_bridge_join(struct dsa_switch *ds,
targeted_ds = dsa_switch_find(info->tree_index, info->sw_index); targeted_ds = dsa_switch_find(info->tree_index, info->sw_index);
targeted_dp = dsa_to_port(targeted_ds, info->port); targeted_dp = dsa_to_port(targeted_ds, info->port);
targeted_rx_vid = dsa_8021q_rx_vid(targeted_ds, info->port); targeted_rx_vid = dsa_tag_8021q_rx_vid(targeted_dp);
dsa_switch_for_each_port(dp, ds) { dsa_switch_for_each_port(dp, ds) {
u16 rx_vid = dsa_8021q_rx_vid(ds, dp->index); u16 rx_vid = dsa_tag_8021q_rx_vid(dp);
if (!dsa_port_tag_8021q_bridge_match(dp, info)) if (!dsa_port_tag_8021q_bridge_match(dp, info))
continue; continue;
...@@ -389,10 +389,10 @@ int dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, ...@@ -389,10 +389,10 @@ int dsa_tag_8021q_bridge_leave(struct dsa_switch *ds,
targeted_ds = dsa_switch_find(info->tree_index, info->sw_index); targeted_ds = dsa_switch_find(info->tree_index, info->sw_index);
targeted_dp = dsa_to_port(targeted_ds, info->port); targeted_dp = dsa_to_port(targeted_ds, info->port);
targeted_rx_vid = dsa_8021q_rx_vid(targeted_ds, info->port); targeted_rx_vid = dsa_tag_8021q_rx_vid(targeted_dp);
dsa_switch_for_each_port(dp, ds) { dsa_switch_for_each_port(dp, ds) {
u16 rx_vid = dsa_8021q_rx_vid(ds, dp->index); u16 rx_vid = dsa_tag_8021q_rx_vid(dp);
if (!dsa_port_tag_8021q_bridge_match(dp, info)) if (!dsa_port_tag_8021q_bridge_match(dp, info))
continue; continue;
...@@ -433,8 +433,8 @@ static int dsa_tag_8021q_port_setup(struct dsa_switch *ds, int port) ...@@ -433,8 +433,8 @@ static int dsa_tag_8021q_port_setup(struct dsa_switch *ds, int port)
{ {
struct dsa_8021q_context *ctx = ds->tag_8021q_ctx; struct dsa_8021q_context *ctx = ds->tag_8021q_ctx;
struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_port *dp = dsa_to_port(ds, port);
u16 rx_vid = dsa_8021q_rx_vid(ds, port); u16 rx_vid = dsa_tag_8021q_rx_vid(dp);
u16 tx_vid = dsa_8021q_tx_vid(ds, port); u16 tx_vid = dsa_tag_8021q_tx_vid(dp);
struct net_device *master; struct net_device *master;
int err; int err;
...@@ -478,8 +478,8 @@ static void dsa_tag_8021q_port_teardown(struct dsa_switch *ds, int port) ...@@ -478,8 +478,8 @@ static void dsa_tag_8021q_port_teardown(struct dsa_switch *ds, int port)
{ {
struct dsa_8021q_context *ctx = ds->tag_8021q_ctx; struct dsa_8021q_context *ctx = ds->tag_8021q_ctx;
struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_port *dp = dsa_to_port(ds, port);
u16 rx_vid = dsa_8021q_rx_vid(ds, port); u16 rx_vid = dsa_tag_8021q_rx_vid(dp);
u16 tx_vid = dsa_8021q_tx_vid(ds, port); u16 tx_vid = dsa_tag_8021q_tx_vid(dp);
struct net_device *master; struct net_device *master;
/* The CPU port is implicitly configured by /* The CPU port is implicitly configured by
......
...@@ -39,9 +39,9 @@ static struct sk_buff *ocelot_xmit(struct sk_buff *skb, ...@@ -39,9 +39,9 @@ static struct sk_buff *ocelot_xmit(struct sk_buff *skb,
struct net_device *netdev) struct net_device *netdev)
{ {
struct dsa_port *dp = dsa_slave_to_port(netdev); struct dsa_port *dp = dsa_slave_to_port(netdev);
u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index);
u16 queue_mapping = skb_get_queue_mapping(skb); u16 queue_mapping = skb_get_queue_mapping(skb);
u8 pcp = netdev_txq_to_tc(netdev, queue_mapping); u8 pcp = netdev_txq_to_tc(netdev, queue_mapping);
u16 tx_vid = dsa_tag_8021q_tx_vid(dp);
struct ethhdr *hdr = eth_hdr(skb); struct ethhdr *hdr = eth_hdr(skb);
if (ocelot_ptp_rew_op(skb) || is_link_local_ether_addr(hdr->h_dest)) if (ocelot_ptp_rew_op(skb) || is_link_local_ether_addr(hdr->h_dest))
......
...@@ -235,9 +235,9 @@ static struct sk_buff *sja1105_xmit(struct sk_buff *skb, ...@@ -235,9 +235,9 @@ static struct sk_buff *sja1105_xmit(struct sk_buff *skb,
struct net_device *netdev) struct net_device *netdev)
{ {
struct dsa_port *dp = dsa_slave_to_port(netdev); struct dsa_port *dp = dsa_slave_to_port(netdev);
u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index);
u16 queue_mapping = skb_get_queue_mapping(skb); u16 queue_mapping = skb_get_queue_mapping(skb);
u8 pcp = netdev_txq_to_tc(netdev, queue_mapping); u8 pcp = netdev_txq_to_tc(netdev, queue_mapping);
u16 tx_vid = dsa_tag_8021q_tx_vid(dp);
if (skb->offload_fwd_mark) if (skb->offload_fwd_mark)
return sja1105_imprecise_xmit(skb, netdev); return sja1105_imprecise_xmit(skb, netdev);
...@@ -263,9 +263,9 @@ static struct sk_buff *sja1110_xmit(struct sk_buff *skb, ...@@ -263,9 +263,9 @@ static struct sk_buff *sja1110_xmit(struct sk_buff *skb,
{ {
struct sk_buff *clone = SJA1105_SKB_CB(skb)->clone; struct sk_buff *clone = SJA1105_SKB_CB(skb)->clone;
struct dsa_port *dp = dsa_slave_to_port(netdev); struct dsa_port *dp = dsa_slave_to_port(netdev);
u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index);
u16 queue_mapping = skb_get_queue_mapping(skb); u16 queue_mapping = skb_get_queue_mapping(skb);
u8 pcp = netdev_txq_to_tc(netdev, queue_mapping); u8 pcp = netdev_txq_to_tc(netdev, queue_mapping);
u16 tx_vid = dsa_tag_8021q_tx_vid(dp);
__be32 *tx_trailer; __be32 *tx_trailer;
__be16 *tx_header; __be16 *tx_header;
int trailer_pos; int trailer_pos;
......
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