net: dsa: tag_8021q: make dsa_8021q_{rx,tx}_vid take dp as argument
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 20 Oct 2021 17:49:55 +0000 (20:49 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Oct 2021 11:44:07 +0000 (12:44 +0100)
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: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105_vl.c
include/linux/dsa/8021q.h
net/dsa/tag_8021q.c
net/dsa/tag_ocelot_8021q.c
net/dsa/tag_sja1105.c

index d555729..f5dca6a 100644 (file)
@@ -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].vlanprior = rule->key.vl.pcp;
                        } 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].vlanprior = 0;
index c7fa4a3..254b165 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/types.h>
 
 struct dsa_switch;
+struct dsa_port;
 struct sk_buff;
 struct net_device;
 
@@ -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_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);
 
index 8f4e0af..72cac2c 100644 (file)
@@ -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
  * 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) |
-              DSA_8021Q_PORT(port);
+       return DSA_8021Q_DIR_TX | DSA_8021Q_SWITCH_ID(dp->ds->index) |
+              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
  * 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) |
-              DSA_8021Q_PORT(port);
+       return DSA_8021Q_DIR_RX | DSA_8021Q_SWITCH_ID(dp->ds->index) |
+              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. */
 int dsa_8021q_rx_switch_id(u16 vid)
@@ -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_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) {
-               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))
                        continue;
@@ -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_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) {
-               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))
                        continue;
@@ -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_port *dp = dsa_to_port(ds, port);
-       u16 rx_vid = dsa_8021q_rx_vid(ds, port);
-       u16 tx_vid = dsa_8021q_tx_vid(ds, port);
+       u16 rx_vid = dsa_tag_8021q_rx_vid(dp);
+       u16 tx_vid = dsa_tag_8021q_tx_vid(dp);
        struct net_device *master;
        int err;
 
@@ -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_port *dp = dsa_to_port(ds, port);
-       u16 rx_vid = dsa_8021q_rx_vid(ds, port);
-       u16 tx_vid = dsa_8021q_tx_vid(ds, port);
+       u16 rx_vid = dsa_tag_8021q_rx_vid(dp);
+       u16 tx_vid = dsa_tag_8021q_tx_vid(dp);
        struct net_device *master;
 
        /* The CPU port is implicitly configured by
index 3412051..a1919ea 100644 (file)
@@ -39,9 +39,9 @@ static struct sk_buff *ocelot_xmit(struct sk_buff *skb,
                                   struct net_device *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);
        u8 pcp = netdev_txq_to_tc(netdev, queue_mapping);
+       u16 tx_vid = dsa_tag_8021q_tx_vid(dp);
        struct ethhdr *hdr = eth_hdr(skb);
 
        if (ocelot_ptp_rew_op(skb) || is_link_local_ether_addr(hdr->h_dest))
index 8b2d458..262c883 100644 (file)
@@ -235,9 +235,9 @@ static struct sk_buff *sja1105_xmit(struct sk_buff *skb,
                                    struct net_device *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);
        u8 pcp = netdev_txq_to_tc(netdev, queue_mapping);
+       u16 tx_vid = dsa_tag_8021q_tx_vid(dp);
 
        if (skb->offload_fwd_mark)
                return sja1105_imprecise_xmit(skb, netdev);
@@ -263,9 +263,9 @@ static struct sk_buff *sja1110_xmit(struct sk_buff *skb,
 {
        struct sk_buff *clone = SJA1105_SKB_CB(skb)->clone;
        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);
        u8 pcp = netdev_txq_to_tc(netdev, queue_mapping);
+       u16 tx_vid = dsa_tag_8021q_tx_vid(dp);
        __be32 *tx_trailer;
        __be16 *tx_header;
        int trailer_pos;