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

net: dsa: sja1105: make dp->priv point directly to sja1105_tagger_data

The design of the sja1105 tagger dp->priv is that each port has a
separate struct sja1105_port, and the sp->data pointer points to a
common struct sja1105_tagger_data.

We have removed all per-port members accessible by the tagger, and now
only struct sja1105_tagger_data remains. Make dp->priv point directly to
this.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6f6770ab
...@@ -257,7 +257,6 @@ struct sja1105_private { ...@@ -257,7 +257,6 @@ struct sja1105_private {
u16 bridge_pvid[SJA1105_MAX_NUM_PORTS]; u16 bridge_pvid[SJA1105_MAX_NUM_PORTS];
u16 tag_8021q_pvid[SJA1105_MAX_NUM_PORTS]; u16 tag_8021q_pvid[SJA1105_MAX_NUM_PORTS];
struct sja1105_flow_block flow_block; struct sja1105_flow_block flow_block;
struct sja1105_port ports[SJA1105_MAX_NUM_PORTS];
/* Serializes transmission of management frames so that /* Serializes transmission of management frames so that
* the switch doesn't confuse them with one another. * the switch doesn't confuse them with one another.
*/ */
......
...@@ -3017,7 +3017,7 @@ static int sja1105_setup_ports(struct sja1105_private *priv) ...@@ -3017,7 +3017,7 @@ static int sja1105_setup_ports(struct sja1105_private *priv)
struct sja1105_tagger_data *tagger_data = &priv->tagger_data; struct sja1105_tagger_data *tagger_data = &priv->tagger_data;
struct dsa_switch *ds = priv->ds; struct dsa_switch *ds = priv->ds;
struct kthread_worker *worker; struct kthread_worker *worker;
int port; struct dsa_port *dp;
worker = kthread_create_worker(0, "dsa%d:%d_xmit", ds->dst->index, worker = kthread_create_worker(0, "dsa%d:%d_xmit", ds->dst->index,
ds->index); ds->index);
...@@ -3031,17 +3031,8 @@ static int sja1105_setup_ports(struct sja1105_private *priv) ...@@ -3031,17 +3031,8 @@ static int sja1105_setup_ports(struct sja1105_private *priv)
tagger_data->xmit_worker = worker; tagger_data->xmit_worker = worker;
tagger_data->xmit_work_fn = sja1105_port_deferred_xmit; tagger_data->xmit_work_fn = sja1105_port_deferred_xmit;
/* Connections between dsa_port and sja1105_port */ dsa_switch_for_each_user_port(dp, ds)
for (port = 0; port < ds->num_ports; port++) { dp->priv = tagger_data;
struct sja1105_port *sp = &priv->ports[port];
struct dsa_port *dp = dsa_to_port(ds, port);
if (!dsa_port_is_user(dp))
continue;
dp->priv = sp;
sp->data = tagger_data;
}
return 0; return 0;
} }
......
...@@ -461,22 +461,24 @@ void sja1110_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb) ...@@ -461,22 +461,24 @@ void sja1110_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
{ {
struct sk_buff *clone = SJA1105_SKB_CB(skb)->clone; struct sk_buff *clone = SJA1105_SKB_CB(skb)->clone;
struct sja1105_private *priv = ds->priv; struct sja1105_private *priv = ds->priv;
struct sja1105_port *sp = &priv->ports[port]; struct sja1105_tagger_data *tagger_data;
u8 ts_id; u8 ts_id;
tagger_data = &priv->tagger_data;
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
spin_lock(&sp->data->meta_lock); spin_lock(&tagger_data->meta_lock);
ts_id = sp->data->ts_id; ts_id = tagger_data->ts_id;
/* Deal automatically with 8-bit wraparound */ /* Deal automatically with 8-bit wraparound */
sp->data->ts_id++; tagger_data->ts_id++;
SJA1105_SKB_CB(clone)->ts_id = ts_id; SJA1105_SKB_CB(clone)->ts_id = ts_id;
spin_unlock(&sp->data->meta_lock); spin_unlock(&tagger_data->meta_lock);
skb_queue_tail(&sp->data->skb_txtstamp_queue, clone); skb_queue_tail(&tagger_data->skb_txtstamp_queue, clone);
} }
/* Called from dsa_skb_tx_timestamp. This callback is just to clone /* Called from dsa_skb_tx_timestamp. This callback is just to clone
......
...@@ -43,9 +43,7 @@ struct sja1105_deferred_xmit_work { ...@@ -43,9 +43,7 @@ struct sja1105_deferred_xmit_work {
struct kthread_work work; struct kthread_work work;
}; };
/* Global tagger data: each struct sja1105_port has a reference to /* Global tagger data */
* the structure defined in struct sja1105_private.
*/
struct sja1105_tagger_data { struct sja1105_tagger_data {
struct sk_buff *stampable_skb; struct sk_buff *stampable_skb;
/* Protects concurrent access to the meta state machine /* Protects concurrent access to the meta state machine
...@@ -72,10 +70,6 @@ struct sja1105_skb_cb { ...@@ -72,10 +70,6 @@ struct sja1105_skb_cb {
#define SJA1105_SKB_CB(skb) \ #define SJA1105_SKB_CB(skb) \
((struct sja1105_skb_cb *)((skb)->cb)) ((struct sja1105_skb_cb *)((skb)->cb))
struct sja1105_port {
struct sja1105_tagger_data *data;
};
/* Timestamps are in units of 8 ns clock ticks (equivalent to /* Timestamps are in units of 8 ns clock ticks (equivalent to
* a fixed 125 MHz clock). * a fixed 125 MHz clock).
*/ */
......
...@@ -125,13 +125,13 @@ static inline bool sja1105_is_meta_frame(const struct sk_buff *skb) ...@@ -125,13 +125,13 @@ static inline bool sja1105_is_meta_frame(const struct sk_buff *skb)
static struct sk_buff *sja1105_defer_xmit(struct dsa_port *dp, static struct sk_buff *sja1105_defer_xmit(struct dsa_port *dp,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct sja1105_tagger_data *tagger_data = dp->priv;
void (*xmit_work_fn)(struct kthread_work *work); void (*xmit_work_fn)(struct kthread_work *work);
struct sja1105_deferred_xmit_work *xmit_work; struct sja1105_deferred_xmit_work *xmit_work;
struct sja1105_port *sp = dp->priv;
struct kthread_worker *xmit_worker; struct kthread_worker *xmit_worker;
xmit_work_fn = sp->data->xmit_work_fn; xmit_work_fn = tagger_data->xmit_work_fn;
xmit_worker = sp->data->xmit_worker; xmit_worker = tagger_data->xmit_worker;
if (!xmit_work_fn || !xmit_worker) if (!xmit_work_fn || !xmit_worker)
return NULL; return NULL;
...@@ -368,32 +368,32 @@ static struct sk_buff ...@@ -368,32 +368,32 @@ static struct sk_buff
*/ */
if (is_link_local) { if (is_link_local) {
struct dsa_port *dp = dsa_slave_to_port(skb->dev); struct dsa_port *dp = dsa_slave_to_port(skb->dev);
struct sja1105_port *sp = dp->priv; struct sja1105_tagger_data *tagger_data = dp->priv;
if (unlikely(!dsa_port_is_sja1105(dp))) if (unlikely(!dsa_port_is_sja1105(dp)))
return skb; return skb;
if (!test_bit(SJA1105_HWTS_RX_EN, &sp->data->state)) if (!test_bit(SJA1105_HWTS_RX_EN, &tagger_data->state))
/* Do normal processing. */ /* Do normal processing. */
return skb; return skb;
spin_lock(&sp->data->meta_lock); spin_lock(&tagger_data->meta_lock);
/* Was this a link-local frame instead of the meta /* Was this a link-local frame instead of the meta
* that we were expecting? * that we were expecting?
*/ */
if (sp->data->stampable_skb) { if (tagger_data->stampable_skb) {
dev_err_ratelimited(dp->ds->dev, dev_err_ratelimited(dp->ds->dev,
"Expected meta frame, is %12llx " "Expected meta frame, is %12llx "
"in the DSA master multicast filter?\n", "in the DSA master multicast filter?\n",
SJA1105_META_DMAC); SJA1105_META_DMAC);
kfree_skb(sp->data->stampable_skb); kfree_skb(tagger_data->stampable_skb);
} }
/* Hold a reference to avoid dsa_switch_rcv /* Hold a reference to avoid dsa_switch_rcv
* from freeing the skb. * from freeing the skb.
*/ */
sp->data->stampable_skb = skb_get(skb); tagger_data->stampable_skb = skb_get(skb);
spin_unlock(&sp->data->meta_lock); spin_unlock(&tagger_data->meta_lock);
/* Tell DSA we got nothing */ /* Tell DSA we got nothing */
return NULL; return NULL;
...@@ -406,7 +406,7 @@ static struct sk_buff ...@@ -406,7 +406,7 @@ static struct sk_buff
*/ */
} else if (is_meta) { } else if (is_meta) {
struct dsa_port *dp = dsa_slave_to_port(skb->dev); struct dsa_port *dp = dsa_slave_to_port(skb->dev);
struct sja1105_port *sp = dp->priv; struct sja1105_tagger_data *tagger_data = dp->priv;
struct sk_buff *stampable_skb; struct sk_buff *stampable_skb;
if (unlikely(!dsa_port_is_sja1105(dp))) if (unlikely(!dsa_port_is_sja1105(dp)))
...@@ -415,13 +415,13 @@ static struct sk_buff ...@@ -415,13 +415,13 @@ static struct sk_buff
/* Drop the meta frame if we're not in the right state /* Drop the meta frame if we're not in the right state
* to process it. * to process it.
*/ */
if (!test_bit(SJA1105_HWTS_RX_EN, &sp->data->state)) if (!test_bit(SJA1105_HWTS_RX_EN, &tagger_data->state))
return NULL; return NULL;
spin_lock(&sp->data->meta_lock); spin_lock(&tagger_data->meta_lock);
stampable_skb = sp->data->stampable_skb; stampable_skb = tagger_data->stampable_skb;
sp->data->stampable_skb = NULL; tagger_data->stampable_skb = NULL;
/* Was this a meta frame instead of the link-local /* Was this a meta frame instead of the link-local
* that we were expecting? * that we were expecting?
...@@ -429,14 +429,14 @@ static struct sk_buff ...@@ -429,14 +429,14 @@ static struct sk_buff
if (!stampable_skb) { if (!stampable_skb) {
dev_err_ratelimited(dp->ds->dev, dev_err_ratelimited(dp->ds->dev,
"Unexpected meta frame\n"); "Unexpected meta frame\n");
spin_unlock(&sp->data->meta_lock); spin_unlock(&tagger_data->meta_lock);
return NULL; return NULL;
} }
if (stampable_skb->dev != skb->dev) { if (stampable_skb->dev != skb->dev) {
dev_err_ratelimited(dp->ds->dev, dev_err_ratelimited(dp->ds->dev,
"Meta frame on wrong port\n"); "Meta frame on wrong port\n");
spin_unlock(&sp->data->meta_lock); spin_unlock(&tagger_data->meta_lock);
return NULL; return NULL;
} }
...@@ -447,7 +447,7 @@ static struct sk_buff ...@@ -447,7 +447,7 @@ static struct sk_buff
skb = stampable_skb; skb = stampable_skb;
sja1105_transfer_meta(skb, meta); sja1105_transfer_meta(skb, meta);
spin_unlock(&sp->data->meta_lock); spin_unlock(&tagger_data->meta_lock);
} }
return skb; return skb;
...@@ -545,8 +545,8 @@ static void sja1110_process_meta_tstamp(struct dsa_switch *ds, int port, ...@@ -545,8 +545,8 @@ static void sja1110_process_meta_tstamp(struct dsa_switch *ds, int port,
{ {
struct sk_buff *skb, *skb_tmp, *skb_match = NULL; struct sk_buff *skb, *skb_tmp, *skb_match = NULL;
struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_port *dp = dsa_to_port(ds, port);
struct sja1105_tagger_data *tagger_data;
struct skb_shared_hwtstamps shwt = {0}; struct skb_shared_hwtstamps shwt = {0};
struct sja1105_port *sp = dp->priv;
if (!dsa_port_is_sja1105(dp)) if (!dsa_port_is_sja1105(dp))
return; return;
...@@ -555,19 +555,21 @@ static void sja1110_process_meta_tstamp(struct dsa_switch *ds, int port, ...@@ -555,19 +555,21 @@ static void sja1110_process_meta_tstamp(struct dsa_switch *ds, int port,
if (dir == SJA1110_META_TSTAMP_RX) if (dir == SJA1110_META_TSTAMP_RX)
return; return;
spin_lock(&sp->data->skb_txtstamp_queue.lock); tagger_data = dp->priv;
skb_queue_walk_safe(&sp->data->skb_txtstamp_queue, skb, skb_tmp) { spin_lock(&tagger_data->skb_txtstamp_queue.lock);
skb_queue_walk_safe(&tagger_data->skb_txtstamp_queue, skb, skb_tmp) {
if (SJA1105_SKB_CB(skb)->ts_id != ts_id) if (SJA1105_SKB_CB(skb)->ts_id != ts_id)
continue; continue;
__skb_unlink(skb, &sp->data->skb_txtstamp_queue); __skb_unlink(skb, &tagger_data->skb_txtstamp_queue);
skb_match = skb; skb_match = skb;
break; break;
} }
spin_unlock(&sp->data->skb_txtstamp_queue.lock); spin_unlock(&tagger_data->skb_txtstamp_queue.lock);
if (WARN_ON(!skb_match)) if (WARN_ON(!skb_match))
return; return;
......
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