Commit e5b0a1b7 authored by David S. Miller's avatar David S. Miller

Merge branch 'sja1110-dsa-tagging'

Vladimir Oltean says:

====================
DSA tagging driver for NXP SJA1110

This series adds support for tagging data and control packets on the new
NXP SJA1110 switch (supported by the sja1105 driver). Up to this point
it used the sja1105 driver, which allowed it to send data packets, but
not PDUs as those required by STP and PTP.

To accommodate this new tagger which has both a header and a trailer, we
need to refactor the entire DSA tagging scheme, to replace the "overhead"
concept with separate "needed_headroom" and "needed_tailroom" concepts,
so that SJA1110 can declare its need for both.

There is also some consolidation work for the receive path of tag_8021q
and its callers (sja1105 and ocelot-8021q).

Changes in v3:
Rebase in front of the "Port the SJA1105 DSA driver to XPCS" series
which seems to have stalled for now.

Changes in v2:
Export the dsa_8021q_rcv and sja1110_process_meta_tstamp symbols to
avoid build errors as modules.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents f244e256 566b18c8
...@@ -93,14 +93,15 @@ A tagging protocol may tag all packets with switch tags of the same length, or ...@@ -93,14 +93,15 @@ A tagging protocol may tag all packets with switch tags of the same length, or
the tag length might vary (for example packets with PTP timestamps might the tag length might vary (for example packets with PTP timestamps might
require an extended switch tag, or there might be one tag length on TX and a require an extended switch tag, or there might be one tag length on TX and a
different one on RX). Either way, the tagging protocol driver must populate the different one on RX). Either way, the tagging protocol driver must populate the
``struct dsa_device_ops::overhead`` with the length in octets of the longest ``struct dsa_device_ops::needed_headroom`` and/or ``struct dsa_device_ops::needed_tailroom``
switch frame header. The DSA framework will automatically adjust the MTU of the with the length in octets of the longest switch frame header/trailer. The DSA
master interface to accomodate for this extra size in order for DSA user ports framework will automatically adjust the MTU of the master interface to
to support the standard MTU (L2 payload length) of 1500 octets. The ``overhead`` accommodate for this extra size in order for DSA user ports to support the
is also used to request from the network stack, on a best-effort basis, the standard MTU (L2 payload length) of 1500 octets. The ``needed_headroom`` and
allocation of packets with a ``needed_headroom`` or ``needed_tailroom`` ``needed_tailroom`` properties are also used to request from the network stack,
sufficient such that the act of pushing the switch tag on transmission of a on a best-effort basis, the allocation of packets with enough extra space such
packet does not cause it to reallocate due to lack of memory. that the act of pushing the switch tag on transmission of a packet does not
cause it to reallocate due to lack of memory.
Even though applications are not expected to parse DSA-specific frame headers, Even though applications are not expected to parse DSA-specific frame headers,
the format on the wire of the tagging protocol represents an Application Binary the format on the wire of the tagging protocol represents an Application Binary
...@@ -169,8 +170,8 @@ The job of this method is to prepare the skb in a way that the switch will ...@@ -169,8 +170,8 @@ The job of this method is to prepare the skb in a way that the switch will
understand what egress port the packet is for (and not deliver it towards other understand what egress port the packet is for (and not deliver it towards other
ports). Typically this is fulfilled by pushing a frame header. Checking for ports). Typically this is fulfilled by pushing a frame header. Checking for
insufficient size in the skb headroom or tailroom is unnecessary provided that insufficient size in the skb headroom or tailroom is unnecessary provided that
the ``overhead`` and ``tail_tag`` properties were filled out properly, because the ``needed_headroom`` and ``needed_tailroom`` properties were filled out
DSA ensures there is enough space before calling this method. properly, because DSA ensures there is enough space before calling this method.
The reception of a packet goes through the tagger's ``rcv`` function. The The reception of a packet goes through the tagger's ``rcv`` function. The
passed ``struct sk_buff *skb`` has ``skb->data`` pointing at passed ``struct sk_buff *skb`` has ``skb->data`` pointing at
......
...@@ -109,6 +109,8 @@ struct sja1105_info { ...@@ -109,6 +109,8 @@ struct sja1105_info {
int num_cbs_shapers; int num_cbs_shapers;
int max_frame_mem; int max_frame_mem;
int num_ports; int num_ports;
bool multiple_cascade_ports;
enum dsa_tag_protocol tag_proto;
const struct sja1105_dynamic_table_ops *dyn_ops; const struct sja1105_dynamic_table_ops *dyn_ops;
const struct sja1105_table_ops *static_ops; const struct sja1105_table_ops *static_ops;
const struct sja1105_regs *regs; const struct sja1105_regs *regs;
...@@ -128,6 +130,8 @@ struct sja1105_info { ...@@ -128,6 +130,8 @@ struct sja1105_info {
const unsigned char *addr, u16 vid); const unsigned char *addr, u16 vid);
void (*ptp_cmd_packing)(u8 *buf, struct sja1105_ptp_cmd *cmd, void (*ptp_cmd_packing)(u8 *buf, struct sja1105_ptp_cmd *cmd,
enum packing_op op); enum packing_op op);
bool (*rxtstamp)(struct dsa_switch *ds, int port, struct sk_buff *skb);
void (*txtstamp)(struct dsa_switch *ds, int port, struct sk_buff *skb);
int (*clocking_setup)(struct sja1105_private *priv); int (*clocking_setup)(struct sja1105_private *priv);
const char *name; const char *name;
bool supports_mii[SJA1105_MAX_NUM_PORTS]; bool supports_mii[SJA1105_MAX_NUM_PORTS];
......
...@@ -654,14 +654,6 @@ static int sja1105_init_general_params(struct sja1105_private *priv) ...@@ -654,14 +654,6 @@ static int sja1105_init_general_params(struct sja1105_private *priv)
.host_port = priv->ds->num_ports, .host_port = priv->ds->num_ports,
/* Default to an invalid value */ /* Default to an invalid value */
.mirr_port = priv->ds->num_ports, .mirr_port = priv->ds->num_ports,
/* Link-local traffic received on casc_port will be forwarded
* to host_port without embedding the source port and device ID
* info in the destination MAC address (presumably because it
* is a cascaded port and a downstream SJA switch already did
* that). Default to an invalid port (to disable the feature)
* and overwrite this if we find any DSA (cascaded) ports.
*/
.casc_port = priv->ds->num_ports,
/* No TTEthernet */ /* No TTEthernet */
.vllupformat = SJA1105_VL_FORMAT_PSFP, .vllupformat = SJA1105_VL_FORMAT_PSFP,
.vlmarker = 0, .vlmarker = 0,
...@@ -673,7 +665,12 @@ static int sja1105_init_general_params(struct sja1105_private *priv) ...@@ -673,7 +665,12 @@ static int sja1105_init_general_params(struct sja1105_private *priv)
*/ */
.tpid = ETH_P_SJA1105, .tpid = ETH_P_SJA1105,
.tpid2 = ETH_P_SJA1105, .tpid2 = ETH_P_SJA1105,
/* Enable the TTEthernet engine on SJA1110 */
.tte_en = true,
/* Set up the EtherType for control packets on SJA1110 */
.header_type = ETH_P_SJA1110,
}; };
struct sja1105_general_params_entry *general_params;
struct dsa_switch *ds = priv->ds; struct dsa_switch *ds = priv->ds;
struct sja1105_table *table; struct sja1105_table *table;
int port; int port;
...@@ -699,12 +696,26 @@ static int sja1105_init_general_params(struct sja1105_private *priv) ...@@ -699,12 +696,26 @@ static int sja1105_init_general_params(struct sja1105_private *priv)
table->entry_count = table->ops->max_entry_count; table->entry_count = table->ops->max_entry_count;
general_params = table->entries;
/* This table only has a single entry */ /* This table only has a single entry */
((struct sja1105_general_params_entry *)table->entries)[0] = general_params[0] = default_general_params;
default_general_params;
sja1110_select_tdmaconfigidx(priv); sja1110_select_tdmaconfigidx(priv);
/* Link-local traffic received on casc_port will be forwarded
* to host_port without embedding the source port and device ID
* info in the destination MAC address, and no RX timestamps will be
* taken either (presumably because it is a cascaded port and a
* downstream SJA switch already did that).
* To disable the feature, we need to do different things depending on
* switch generation. On SJA1105 we need to set an invalid port, while
* on SJA1110 which support multiple cascaded ports, this field is a
* bitmask so it must be left zero.
*/
if (!priv->info->multiple_cascade_ports)
general_params->casc_port = ds->num_ports;
return 0; return 0;
} }
...@@ -2165,7 +2176,9 @@ static enum dsa_tag_protocol ...@@ -2165,7 +2176,9 @@ static enum dsa_tag_protocol
sja1105_get_tag_protocol(struct dsa_switch *ds, int port, sja1105_get_tag_protocol(struct dsa_switch *ds, int port,
enum dsa_tag_protocol mp) enum dsa_tag_protocol mp)
{ {
return DSA_TAG_PROTO_SJA1105; struct sja1105_private *priv = ds->priv;
return priv->info->tag_proto;
} }
static int sja1105_find_free_subvlan(u16 *subvlan_map, bool pvid) static int sja1105_find_free_subvlan(u16 *subvlan_map, bool pvid)
......
...@@ -79,6 +79,7 @@ static int sja1105_change_rxtstamping(struct sja1105_private *priv, ...@@ -79,6 +79,7 @@ static int sja1105_change_rxtstamping(struct sja1105_private *priv,
priv->tagger_data.stampable_skb = NULL; priv->tagger_data.stampable_skb = NULL;
} }
ptp_cancel_worker_sync(ptp_data->clock); ptp_cancel_worker_sync(ptp_data->clock);
skb_queue_purge(&ptp_data->skb_txtstamp_queue);
skb_queue_purge(&ptp_data->skb_rxtstamp_queue); skb_queue_purge(&ptp_data->skb_rxtstamp_queue);
return sja1105_static_config_reload(priv, SJA1105_RX_HWTSTAMPING); return sja1105_static_config_reload(priv, SJA1105_RX_HWTSTAMPING);
...@@ -397,7 +398,7 @@ static long sja1105_rxtstamp_work(struct ptp_clock_info *ptp) ...@@ -397,7 +398,7 @@ static long sja1105_rxtstamp_work(struct ptp_clock_info *ptp)
*shwt = (struct skb_shared_hwtstamps) {0}; *shwt = (struct skb_shared_hwtstamps) {0};
ts = SJA1105_SKB_CB(skb)->meta_tstamp; ts = SJA1105_SKB_CB(skb)->tstamp;
ts = sja1105_tstamp_reconstruct(ds, ticks, ts); ts = sja1105_tstamp_reconstruct(ds, ticks, ts);
shwt->hwtstamp = ns_to_ktime(sja1105_ticks_to_ns(ts)); shwt->hwtstamp = ns_to_ktime(sja1105_ticks_to_ns(ts));
...@@ -413,9 +414,7 @@ static long sja1105_rxtstamp_work(struct ptp_clock_info *ptp) ...@@ -413,9 +414,7 @@ static long sja1105_rxtstamp_work(struct ptp_clock_info *ptp)
return -1; return -1;
} }
/* Called from dsa_skb_defer_rx_timestamp */ bool sja1105_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
bool sja1105_port_rxtstamp(struct dsa_switch *ds, int port,
struct sk_buff *skb, unsigned int type)
{ {
struct sja1105_private *priv = ds->priv; struct sja1105_private *priv = ds->priv;
struct sja1105_ptp_data *ptp_data = &priv->ptp_data; struct sja1105_ptp_data *ptp_data = &priv->ptp_data;
...@@ -431,6 +430,89 @@ bool sja1105_port_rxtstamp(struct dsa_switch *ds, int port, ...@@ -431,6 +430,89 @@ bool sja1105_port_rxtstamp(struct dsa_switch *ds, int port,
return true; return true;
} }
bool sja1110_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
{
struct skb_shared_hwtstamps *shwt = skb_hwtstamps(skb);
u64 ts = SJA1105_SKB_CB(skb)->tstamp;
*shwt = (struct skb_shared_hwtstamps) {0};
shwt->hwtstamp = ns_to_ktime(sja1105_ticks_to_ns(ts));
/* Don't defer */
return false;
}
/* Called from dsa_skb_defer_rx_timestamp */
bool sja1105_port_rxtstamp(struct dsa_switch *ds, int port,
struct sk_buff *skb, unsigned int type)
{
struct sja1105_private *priv = ds->priv;
return priv->info->rxtstamp(ds, port, skb);
}
void sja1110_process_meta_tstamp(struct dsa_switch *ds, int port, u8 ts_id,
enum sja1110_meta_tstamp dir, u64 tstamp)
{
struct sja1105_private *priv = ds->priv;
struct sja1105_ptp_data *ptp_data = &priv->ptp_data;
struct sk_buff *skb, *skb_tmp, *skb_match = NULL;
struct skb_shared_hwtstamps shwt = {0};
/* We don't care about RX timestamps on the CPU port */
if (dir == SJA1110_META_TSTAMP_RX)
return;
spin_lock(&ptp_data->skb_txtstamp_queue.lock);
skb_queue_walk_safe(&ptp_data->skb_txtstamp_queue, skb, skb_tmp) {
if (SJA1105_SKB_CB(skb)->ts_id != ts_id)
continue;
__skb_unlink(skb, &ptp_data->skb_txtstamp_queue);
skb_match = skb;
break;
}
spin_unlock(&ptp_data->skb_txtstamp_queue.lock);
if (WARN_ON(!skb_match))
return;
shwt.hwtstamp = ns_to_ktime(sja1105_ticks_to_ns(tstamp));
skb_complete_tx_timestamp(skb_match, &shwt);
}
EXPORT_SYMBOL_GPL(sja1110_process_meta_tstamp);
/* In addition to cloning the skb which is done by the common
* sja1105_port_txtstamp, we need to generate a timestamp ID and save the
* packet to the TX timestamping queue.
*/
void sja1110_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
{
struct sk_buff *clone = SJA1105_SKB_CB(skb)->clone;
struct sja1105_private *priv = ds->priv;
struct sja1105_ptp_data *ptp_data = &priv->ptp_data;
struct sja1105_port *sp = &priv->ports[port];
u8 ts_id;
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
spin_lock(&sp->data->meta_lock);
ts_id = sp->data->ts_id;
/* Deal automatically with 8-bit wraparound */
sp->data->ts_id++;
SJA1105_SKB_CB(clone)->ts_id = ts_id;
spin_unlock(&sp->data->meta_lock);
skb_queue_tail(&ptp_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
* the skb and have it available in SJA1105_SKB_CB in the .port_deferred_xmit * the skb and have it available in SJA1105_SKB_CB in the .port_deferred_xmit
* callback, where we will timestamp it synchronously. * callback, where we will timestamp it synchronously.
...@@ -449,6 +531,9 @@ void sja1105_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb) ...@@ -449,6 +531,9 @@ void sja1105_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
return; return;
SJA1105_SKB_CB(skb)->clone = clone; SJA1105_SKB_CB(skb)->clone = clone;
if (priv->info->txtstamp)
priv->info->txtstamp(ds, port, skb);
} }
static int sja1105_ptp_reset(struct dsa_switch *ds) static int sja1105_ptp_reset(struct dsa_switch *ds)
...@@ -865,7 +950,10 @@ int sja1105_ptp_clock_register(struct dsa_switch *ds) ...@@ -865,7 +950,10 @@ int sja1105_ptp_clock_register(struct dsa_switch *ds)
.n_per_out = 1, .n_per_out = 1,
}; };
/* Only used on SJA1105 */
skb_queue_head_init(&ptp_data->skb_rxtstamp_queue); skb_queue_head_init(&ptp_data->skb_rxtstamp_queue);
/* Only used on SJA1110 */
skb_queue_head_init(&ptp_data->skb_txtstamp_queue);
spin_lock_init(&tagger_data->meta_lock); spin_lock_init(&tagger_data->meta_lock);
ptp_data->clock = ptp_clock_register(&ptp_data->caps, ds->dev); ptp_data->clock = ptp_clock_register(&ptp_data->caps, ds->dev);
...@@ -890,6 +978,7 @@ void sja1105_ptp_clock_unregister(struct dsa_switch *ds) ...@@ -890,6 +978,7 @@ void sja1105_ptp_clock_unregister(struct dsa_switch *ds)
del_timer_sync(&ptp_data->extts_timer); del_timer_sync(&ptp_data->extts_timer);
ptp_cancel_worker_sync(ptp_data->clock); ptp_cancel_worker_sync(ptp_data->clock);
skb_queue_purge(&ptp_data->skb_txtstamp_queue);
skb_queue_purge(&ptp_data->skb_rxtstamp_queue); skb_queue_purge(&ptp_data->skb_rxtstamp_queue);
ptp_clock_unregister(ptp_data->clock); ptp_clock_unregister(ptp_data->clock);
ptp_data->clock = NULL; ptp_data->clock = NULL;
......
...@@ -75,7 +75,12 @@ struct sja1105_ptp_cmd { ...@@ -75,7 +75,12 @@ struct sja1105_ptp_cmd {
struct sja1105_ptp_data { struct sja1105_ptp_data {
struct timer_list extts_timer; struct timer_list extts_timer;
/* Used only on SJA1105 to reconstruct partial timestamps */
struct sk_buff_head skb_rxtstamp_queue; struct sk_buff_head skb_rxtstamp_queue;
/* Used on SJA1110 where meta frames are generated only for
* 2-step TX timestamps
*/
struct sk_buff_head skb_txtstamp_queue;
struct ptp_clock_info caps; struct ptp_clock_info caps;
struct ptp_clock *clock; struct ptp_clock *clock;
struct sja1105_ptp_cmd cmd; struct sja1105_ptp_cmd cmd;
...@@ -122,6 +127,10 @@ int __sja1105_ptp_adjtime(struct dsa_switch *ds, s64 delta); ...@@ -122,6 +127,10 @@ int __sja1105_ptp_adjtime(struct dsa_switch *ds, s64 delta);
int sja1105_ptp_commit(struct dsa_switch *ds, struct sja1105_ptp_cmd *cmd, int sja1105_ptp_commit(struct dsa_switch *ds, struct sja1105_ptp_cmd *cmd,
sja1105_spi_rw_mode_t rw); sja1105_spi_rw_mode_t rw);
bool sja1105_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb);
bool sja1110_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb);
void sja1110_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb);
#else #else
struct sja1105_ptp_cmd; struct sja1105_ptp_cmd;
...@@ -184,6 +193,10 @@ static inline int sja1105_ptp_commit(struct dsa_switch *ds, ...@@ -184,6 +193,10 @@ static inline int sja1105_ptp_commit(struct dsa_switch *ds,
#define sja1105_hwtstamp_set NULL #define sja1105_hwtstamp_set NULL
#define sja1105_rxtstamp NULL
#define sja1110_rxtstamp NULL
#define sja1110_txtstamp NULL
#endif /* IS_ENABLED(CONFIG_NET_DSA_SJA1105_PTP) */ #endif /* IS_ENABLED(CONFIG_NET_DSA_SJA1105_PTP) */
#endif /* _SJA1105_PTP_H */ #endif /* _SJA1105_PTP_H */
...@@ -569,6 +569,7 @@ const struct sja1105_info sja1105e_info = { ...@@ -569,6 +569,7 @@ const struct sja1105_info sja1105e_info = {
.static_ops = sja1105e_table_ops, .static_ops = sja1105e_table_ops,
.dyn_ops = sja1105et_dyn_ops, .dyn_ops = sja1105et_dyn_ops,
.qinq_tpid = ETH_P_8021Q, .qinq_tpid = ETH_P_8021Q,
.tag_proto = DSA_TAG_PROTO_SJA1105,
.can_limit_mcast_flood = false, .can_limit_mcast_flood = false,
.ptp_ts_bits = 24, .ptp_ts_bits = 24,
.ptpegr_ts_bytes = 4, .ptpegr_ts_bytes = 4,
...@@ -579,6 +580,7 @@ const struct sja1105_info sja1105e_info = { ...@@ -579,6 +580,7 @@ const struct sja1105_info sja1105e_info = {
.fdb_add_cmd = sja1105et_fdb_add, .fdb_add_cmd = sja1105et_fdb_add,
.fdb_del_cmd = sja1105et_fdb_del, .fdb_del_cmd = sja1105et_fdb_del,
.ptp_cmd_packing = sja1105et_ptp_cmd_packing, .ptp_cmd_packing = sja1105et_ptp_cmd_packing,
.rxtstamp = sja1105_rxtstamp,
.clocking_setup = sja1105_clocking_setup, .clocking_setup = sja1105_clocking_setup,
.regs = &sja1105et_regs, .regs = &sja1105et_regs,
.port_speed = { .port_speed = {
...@@ -600,6 +602,7 @@ const struct sja1105_info sja1105t_info = { ...@@ -600,6 +602,7 @@ const struct sja1105_info sja1105t_info = {
.static_ops = sja1105t_table_ops, .static_ops = sja1105t_table_ops,
.dyn_ops = sja1105et_dyn_ops, .dyn_ops = sja1105et_dyn_ops,
.qinq_tpid = ETH_P_8021Q, .qinq_tpid = ETH_P_8021Q,
.tag_proto = DSA_TAG_PROTO_SJA1105,
.can_limit_mcast_flood = false, .can_limit_mcast_flood = false,
.ptp_ts_bits = 24, .ptp_ts_bits = 24,
.ptpegr_ts_bytes = 4, .ptpegr_ts_bytes = 4,
...@@ -610,6 +613,7 @@ const struct sja1105_info sja1105t_info = { ...@@ -610,6 +613,7 @@ const struct sja1105_info sja1105t_info = {
.fdb_add_cmd = sja1105et_fdb_add, .fdb_add_cmd = sja1105et_fdb_add,
.fdb_del_cmd = sja1105et_fdb_del, .fdb_del_cmd = sja1105et_fdb_del,
.ptp_cmd_packing = sja1105et_ptp_cmd_packing, .ptp_cmd_packing = sja1105et_ptp_cmd_packing,
.rxtstamp = sja1105_rxtstamp,
.clocking_setup = sja1105_clocking_setup, .clocking_setup = sja1105_clocking_setup,
.regs = &sja1105et_regs, .regs = &sja1105et_regs,
.port_speed = { .port_speed = {
...@@ -631,6 +635,7 @@ const struct sja1105_info sja1105p_info = { ...@@ -631,6 +635,7 @@ const struct sja1105_info sja1105p_info = {
.static_ops = sja1105p_table_ops, .static_ops = sja1105p_table_ops,
.dyn_ops = sja1105pqrs_dyn_ops, .dyn_ops = sja1105pqrs_dyn_ops,
.qinq_tpid = ETH_P_8021AD, .qinq_tpid = ETH_P_8021AD,
.tag_proto = DSA_TAG_PROTO_SJA1105,
.can_limit_mcast_flood = true, .can_limit_mcast_flood = true,
.ptp_ts_bits = 32, .ptp_ts_bits = 32,
.ptpegr_ts_bytes = 8, .ptpegr_ts_bytes = 8,
...@@ -642,6 +647,7 @@ const struct sja1105_info sja1105p_info = { ...@@ -642,6 +647,7 @@ const struct sja1105_info sja1105p_info = {
.fdb_add_cmd = sja1105pqrs_fdb_add, .fdb_add_cmd = sja1105pqrs_fdb_add,
.fdb_del_cmd = sja1105pqrs_fdb_del, .fdb_del_cmd = sja1105pqrs_fdb_del,
.ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing, .ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing,
.rxtstamp = sja1105_rxtstamp,
.clocking_setup = sja1105_clocking_setup, .clocking_setup = sja1105_clocking_setup,
.regs = &sja1105pqrs_regs, .regs = &sja1105pqrs_regs,
.port_speed = { .port_speed = {
...@@ -663,6 +669,7 @@ const struct sja1105_info sja1105q_info = { ...@@ -663,6 +669,7 @@ const struct sja1105_info sja1105q_info = {
.static_ops = sja1105q_table_ops, .static_ops = sja1105q_table_ops,
.dyn_ops = sja1105pqrs_dyn_ops, .dyn_ops = sja1105pqrs_dyn_ops,
.qinq_tpid = ETH_P_8021AD, .qinq_tpid = ETH_P_8021AD,
.tag_proto = DSA_TAG_PROTO_SJA1105,
.can_limit_mcast_flood = true, .can_limit_mcast_flood = true,
.ptp_ts_bits = 32, .ptp_ts_bits = 32,
.ptpegr_ts_bytes = 8, .ptpegr_ts_bytes = 8,
...@@ -674,6 +681,7 @@ const struct sja1105_info sja1105q_info = { ...@@ -674,6 +681,7 @@ const struct sja1105_info sja1105q_info = {
.fdb_add_cmd = sja1105pqrs_fdb_add, .fdb_add_cmd = sja1105pqrs_fdb_add,
.fdb_del_cmd = sja1105pqrs_fdb_del, .fdb_del_cmd = sja1105pqrs_fdb_del,
.ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing, .ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing,
.rxtstamp = sja1105_rxtstamp,
.clocking_setup = sja1105_clocking_setup, .clocking_setup = sja1105_clocking_setup,
.regs = &sja1105pqrs_regs, .regs = &sja1105pqrs_regs,
.port_speed = { .port_speed = {
...@@ -695,6 +703,7 @@ const struct sja1105_info sja1105r_info = { ...@@ -695,6 +703,7 @@ const struct sja1105_info sja1105r_info = {
.static_ops = sja1105r_table_ops, .static_ops = sja1105r_table_ops,
.dyn_ops = sja1105pqrs_dyn_ops, .dyn_ops = sja1105pqrs_dyn_ops,
.qinq_tpid = ETH_P_8021AD, .qinq_tpid = ETH_P_8021AD,
.tag_proto = DSA_TAG_PROTO_SJA1105,
.can_limit_mcast_flood = true, .can_limit_mcast_flood = true,
.ptp_ts_bits = 32, .ptp_ts_bits = 32,
.ptpegr_ts_bytes = 8, .ptpegr_ts_bytes = 8,
...@@ -706,6 +715,7 @@ const struct sja1105_info sja1105r_info = { ...@@ -706,6 +715,7 @@ const struct sja1105_info sja1105r_info = {
.fdb_add_cmd = sja1105pqrs_fdb_add, .fdb_add_cmd = sja1105pqrs_fdb_add,
.fdb_del_cmd = sja1105pqrs_fdb_del, .fdb_del_cmd = sja1105pqrs_fdb_del,
.ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing, .ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing,
.rxtstamp = sja1105_rxtstamp,
.clocking_setup = sja1105_clocking_setup, .clocking_setup = sja1105_clocking_setup,
.regs = &sja1105pqrs_regs, .regs = &sja1105pqrs_regs,
.port_speed = { .port_speed = {
...@@ -729,6 +739,7 @@ const struct sja1105_info sja1105s_info = { ...@@ -729,6 +739,7 @@ const struct sja1105_info sja1105s_info = {
.dyn_ops = sja1105pqrs_dyn_ops, .dyn_ops = sja1105pqrs_dyn_ops,
.regs = &sja1105pqrs_regs, .regs = &sja1105pqrs_regs,
.qinq_tpid = ETH_P_8021AD, .qinq_tpid = ETH_P_8021AD,
.tag_proto = DSA_TAG_PROTO_SJA1105,
.can_limit_mcast_flood = true, .can_limit_mcast_flood = true,
.ptp_ts_bits = 32, .ptp_ts_bits = 32,
.ptpegr_ts_bytes = 8, .ptpegr_ts_bytes = 8,
...@@ -740,6 +751,7 @@ const struct sja1105_info sja1105s_info = { ...@@ -740,6 +751,7 @@ const struct sja1105_info sja1105s_info = {
.fdb_add_cmd = sja1105pqrs_fdb_add, .fdb_add_cmd = sja1105pqrs_fdb_add,
.fdb_del_cmd = sja1105pqrs_fdb_del, .fdb_del_cmd = sja1105pqrs_fdb_del,
.ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing, .ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing,
.rxtstamp = sja1105_rxtstamp,
.clocking_setup = sja1105_clocking_setup, .clocking_setup = sja1105_clocking_setup,
.port_speed = { .port_speed = {
[SJA1105_SPEED_AUTO] = 0, [SJA1105_SPEED_AUTO] = 0,
...@@ -762,7 +774,9 @@ const struct sja1105_info sja1110a_info = { ...@@ -762,7 +774,9 @@ const struct sja1105_info sja1110a_info = {
.dyn_ops = sja1110_dyn_ops, .dyn_ops = sja1110_dyn_ops,
.regs = &sja1110_regs, .regs = &sja1110_regs,
.qinq_tpid = ETH_P_8021AD, .qinq_tpid = ETH_P_8021AD,
.tag_proto = DSA_TAG_PROTO_SJA1110,
.can_limit_mcast_flood = true, .can_limit_mcast_flood = true,
.multiple_cascade_ports = true,
.ptp_ts_bits = 32, .ptp_ts_bits = 32,
.ptpegr_ts_bytes = 8, .ptpegr_ts_bytes = 8,
.max_frame_mem = SJA1110_MAX_FRAME_MEMORY, .max_frame_mem = SJA1110_MAX_FRAME_MEMORY,
...@@ -773,6 +787,8 @@ const struct sja1105_info sja1110a_info = { ...@@ -773,6 +787,8 @@ const struct sja1105_info sja1110a_info = {
.fdb_add_cmd = sja1105pqrs_fdb_add, .fdb_add_cmd = sja1105pqrs_fdb_add,
.fdb_del_cmd = sja1105pqrs_fdb_del, .fdb_del_cmd = sja1105pqrs_fdb_del,
.ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing, .ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing,
.rxtstamp = sja1110_rxtstamp,
.txtstamp = sja1110_txtstamp,
.clocking_setup = sja1110_clocking_setup, .clocking_setup = sja1110_clocking_setup,
.port_speed = { .port_speed = {
[SJA1105_SPEED_AUTO] = 0, [SJA1105_SPEED_AUTO] = 0,
...@@ -807,7 +823,9 @@ const struct sja1105_info sja1110b_info = { ...@@ -807,7 +823,9 @@ const struct sja1105_info sja1110b_info = {
.dyn_ops = sja1110_dyn_ops, .dyn_ops = sja1110_dyn_ops,
.regs = &sja1110_regs, .regs = &sja1110_regs,
.qinq_tpid = ETH_P_8021AD, .qinq_tpid = ETH_P_8021AD,
.tag_proto = DSA_TAG_PROTO_SJA1110,
.can_limit_mcast_flood = true, .can_limit_mcast_flood = true,
.multiple_cascade_ports = true,
.ptp_ts_bits = 32, .ptp_ts_bits = 32,
.ptpegr_ts_bytes = 8, .ptpegr_ts_bytes = 8,
.max_frame_mem = SJA1110_MAX_FRAME_MEMORY, .max_frame_mem = SJA1110_MAX_FRAME_MEMORY,
...@@ -818,6 +836,8 @@ const struct sja1105_info sja1110b_info = { ...@@ -818,6 +836,8 @@ const struct sja1105_info sja1110b_info = {
.fdb_add_cmd = sja1105pqrs_fdb_add, .fdb_add_cmd = sja1105pqrs_fdb_add,
.fdb_del_cmd = sja1105pqrs_fdb_del, .fdb_del_cmd = sja1105pqrs_fdb_del,
.ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing, .ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing,
.rxtstamp = sja1110_rxtstamp,
.txtstamp = sja1110_txtstamp,
.clocking_setup = sja1110_clocking_setup, .clocking_setup = sja1110_clocking_setup,
.port_speed = { .port_speed = {
[SJA1105_SPEED_AUTO] = 0, [SJA1105_SPEED_AUTO] = 0,
...@@ -852,7 +872,9 @@ const struct sja1105_info sja1110c_info = { ...@@ -852,7 +872,9 @@ const struct sja1105_info sja1110c_info = {
.dyn_ops = sja1110_dyn_ops, .dyn_ops = sja1110_dyn_ops,
.regs = &sja1110_regs, .regs = &sja1110_regs,
.qinq_tpid = ETH_P_8021AD, .qinq_tpid = ETH_P_8021AD,
.tag_proto = DSA_TAG_PROTO_SJA1110,
.can_limit_mcast_flood = true, .can_limit_mcast_flood = true,
.multiple_cascade_ports = true,
.ptp_ts_bits = 32, .ptp_ts_bits = 32,
.ptpegr_ts_bytes = 8, .ptpegr_ts_bytes = 8,
.max_frame_mem = SJA1110_MAX_FRAME_MEMORY, .max_frame_mem = SJA1110_MAX_FRAME_MEMORY,
...@@ -863,6 +885,8 @@ const struct sja1105_info sja1110c_info = { ...@@ -863,6 +885,8 @@ const struct sja1105_info sja1110c_info = {
.fdb_add_cmd = sja1105pqrs_fdb_add, .fdb_add_cmd = sja1105pqrs_fdb_add,
.fdb_del_cmd = sja1105pqrs_fdb_del, .fdb_del_cmd = sja1105pqrs_fdb_del,
.ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing, .ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing,
.rxtstamp = sja1110_rxtstamp,
.txtstamp = sja1110_txtstamp,
.clocking_setup = sja1110_clocking_setup, .clocking_setup = sja1110_clocking_setup,
.port_speed = { .port_speed = {
[SJA1105_SPEED_AUTO] = 0, [SJA1105_SPEED_AUTO] = 0,
...@@ -897,7 +921,9 @@ const struct sja1105_info sja1110d_info = { ...@@ -897,7 +921,9 @@ const struct sja1105_info sja1110d_info = {
.dyn_ops = sja1110_dyn_ops, .dyn_ops = sja1110_dyn_ops,
.regs = &sja1110_regs, .regs = &sja1110_regs,
.qinq_tpid = ETH_P_8021AD, .qinq_tpid = ETH_P_8021AD,
.tag_proto = DSA_TAG_PROTO_SJA1110,
.can_limit_mcast_flood = true, .can_limit_mcast_flood = true,
.multiple_cascade_ports = true,
.ptp_ts_bits = 32, .ptp_ts_bits = 32,
.ptpegr_ts_bytes = 8, .ptpegr_ts_bytes = 8,
.max_frame_mem = SJA1110_MAX_FRAME_MEMORY, .max_frame_mem = SJA1110_MAX_FRAME_MEMORY,
...@@ -908,6 +934,8 @@ const struct sja1105_info sja1110d_info = { ...@@ -908,6 +934,8 @@ const struct sja1105_info sja1110d_info = {
.fdb_add_cmd = sja1105pqrs_fdb_add, .fdb_add_cmd = sja1105pqrs_fdb_add,
.fdb_del_cmd = sja1105pqrs_fdb_del, .fdb_del_cmd = sja1105pqrs_fdb_del,
.ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing, .ptp_cmd_packing = sja1105pqrs_ptp_cmd_packing,
.rxtstamp = sja1110_rxtstamp,
.txtstamp = sja1110_txtstamp,
.clocking_setup = sja1110_clocking_setup, .clocking_setup = sja1110_clocking_setup,
.port_speed = { .port_speed = {
[SJA1105_SPEED_AUTO] = 0, [SJA1105_SPEED_AUTO] = 0,
......
...@@ -212,6 +212,7 @@ size_t sja1110_general_params_entry_packing(void *buf, void *entry_ptr, ...@@ -212,6 +212,7 @@ size_t sja1110_general_params_entry_packing(void *buf, void *entry_ptr,
sja1105_packing(buf, &entry->egrmirrdei, 110, 110, size, op); sja1105_packing(buf, &entry->egrmirrdei, 110, 110, size, op);
sja1105_packing(buf, &entry->replay_port, 109, 106, size, op); sja1105_packing(buf, &entry->replay_port, 109, 106, size, op);
sja1105_packing(buf, &entry->tdmaconfigidx, 70, 67, size, op); sja1105_packing(buf, &entry->tdmaconfigidx, 70, 67, size, op);
sja1105_packing(buf, &entry->header_type, 64, 49, size, op);
sja1105_packing(buf, &entry->tte_en, 16, 16, size, op); sja1105_packing(buf, &entry->tte_en, 16, 16, size, op);
return size; return size;
} }
......
...@@ -217,6 +217,7 @@ struct sja1105_general_params_entry { ...@@ -217,6 +217,7 @@ struct sja1105_general_params_entry {
/* SJA1110 only */ /* SJA1110 only */
u64 tte_en; u64 tte_en;
u64 tdmaconfigidx; u64 tdmaconfigidx;
u64 header_type;
}; };
struct sja1105_schedule_entry_points_entry { struct sja1105_schedule_entry_points_entry {
......
...@@ -37,8 +37,6 @@ struct dsa_8021q_context { ...@@ -37,8 +37,6 @@ struct dsa_8021q_context {
#define DSA_8021Q_N_SUBVLAN 8 #define DSA_8021Q_N_SUBVLAN 8
#if IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q)
int dsa_8021q_setup(struct dsa_8021q_context *ctx, bool enabled); int dsa_8021q_setup(struct dsa_8021q_context *ctx, bool enabled);
int dsa_8021q_crosschip_bridge_join(struct dsa_8021q_context *ctx, int port, int dsa_8021q_crosschip_bridge_join(struct dsa_8021q_context *ctx, int port,
...@@ -52,6 +50,9 @@ int dsa_8021q_crosschip_bridge_leave(struct dsa_8021q_context *ctx, int port, ...@@ -52,6 +50,9 @@ int dsa_8021q_crosschip_bridge_leave(struct dsa_8021q_context *ctx, int port,
struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev,
u16 tpid, u16 tci); u16 tpid, u16 tci);
void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id,
int *subvlan);
u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port); u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port);
u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port); u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port);
...@@ -70,78 +71,4 @@ bool vid_is_dsa_8021q_txvlan(u16 vid); ...@@ -70,78 +71,4 @@ bool vid_is_dsa_8021q_txvlan(u16 vid);
bool vid_is_dsa_8021q(u16 vid); bool vid_is_dsa_8021q(u16 vid);
#else
int dsa_8021q_setup(struct dsa_8021q_context *ctx, bool enabled)
{
return 0;
}
int dsa_8021q_crosschip_bridge_join(struct dsa_8021q_context *ctx, int port,
struct dsa_8021q_context *other_ctx,
int other_port)
{
return 0;
}
int dsa_8021q_crosschip_bridge_leave(struct dsa_8021q_context *ctx, int port,
struct dsa_8021q_context *other_ctx,
int other_port)
{
return 0;
}
struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev,
u16 tpid, u16 tci)
{
return NULL;
}
u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port)
{
return 0;
}
u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port)
{
return 0;
}
u16 dsa_8021q_rx_vid_subvlan(struct dsa_switch *ds, int port, u16 subvlan)
{
return 0;
}
int dsa_8021q_rx_switch_id(u16 vid)
{
return 0;
}
int dsa_8021q_rx_source_port(u16 vid)
{
return 0;
}
u16 dsa_8021q_rx_subvlan(u16 vid)
{
return 0;
}
bool vid_is_dsa_8021q_rxvlan(u16 vid)
{
return false;
}
bool vid_is_dsa_8021q_txvlan(u16 vid)
{
return false;
}
bool vid_is_dsa_8021q(u16 vid)
{
return false;
}
#endif /* IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q) */
#endif /* _NET_DSA_8021Q_H */ #endif /* _NET_DSA_8021Q_H */
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#define ETH_P_SJA1105 ETH_P_DSA_8021Q #define ETH_P_SJA1105 ETH_P_DSA_8021Q
#define ETH_P_SJA1105_META 0x0008 #define ETH_P_SJA1105_META 0x0008
#define ETH_P_SJA1110 0xdadc
/* IEEE 802.3 Annex 57A: Slow Protocols PDUs (01:80:C2:xx:xx:xx) */ /* IEEE 802.3 Annex 57A: Slow Protocols PDUs (01:80:C2:xx:xx:xx) */
#define SJA1105_LINKLOCAL_FILTER_A 0x0180C2000000ull #define SJA1105_LINKLOCAL_FILTER_A 0x0180C2000000ull
...@@ -44,11 +45,14 @@ struct sja1105_tagger_data { ...@@ -44,11 +45,14 @@ struct sja1105_tagger_data {
*/ */
spinlock_t meta_lock; spinlock_t meta_lock;
unsigned long state; unsigned long state;
u8 ts_id;
}; };
struct sja1105_skb_cb { struct sja1105_skb_cb {
struct sk_buff *clone; struct sk_buff *clone;
u32 meta_tstamp; u64 tstamp;
/* Only valid for packets cloned for 2-step TX timestamping */
u8 ts_id;
}; };
#define SJA1105_SKB_CB(skb) \ #define SJA1105_SKB_CB(skb) \
...@@ -65,4 +69,24 @@ struct sja1105_port { ...@@ -65,4 +69,24 @@ struct sja1105_port {
u16 xmit_tpid; u16 xmit_tpid;
}; };
enum sja1110_meta_tstamp {
SJA1110_META_TSTAMP_TX = 0,
SJA1110_META_TSTAMP_RX = 1,
};
#if IS_ENABLED(CONFIG_NET_DSA_SJA1105_PTP)
void sja1110_process_meta_tstamp(struct dsa_switch *ds, int port, u8 ts_id,
enum sja1110_meta_tstamp dir, u64 tstamp);
#else
static inline void sja1110_process_meta_tstamp(struct dsa_switch *ds, int port,
u8 ts_id, enum sja1110_meta_tstamp dir,
u64 tstamp)
{
}
#endif /* IS_ENABLED(CONFIG_NET_DSA_SJA1105_PTP) */
#endif /* _NET_DSA_SJA1105_H */ #endif /* _NET_DSA_SJA1105_H */
...@@ -50,6 +50,7 @@ struct phylink_link_state; ...@@ -50,6 +50,7 @@ struct phylink_link_state;
#define DSA_TAG_PROTO_OCELOT_8021Q_VALUE 20 #define DSA_TAG_PROTO_OCELOT_8021Q_VALUE 20
#define DSA_TAG_PROTO_SEVILLE_VALUE 21 #define DSA_TAG_PROTO_SEVILLE_VALUE 21
#define DSA_TAG_PROTO_BRCM_LEGACY_VALUE 22 #define DSA_TAG_PROTO_BRCM_LEGACY_VALUE 22
#define DSA_TAG_PROTO_SJA1110_VALUE 23
enum dsa_tag_protocol { enum dsa_tag_protocol {
DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE, DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE,
...@@ -75,6 +76,7 @@ enum dsa_tag_protocol { ...@@ -75,6 +76,7 @@ enum dsa_tag_protocol {
DSA_TAG_PROTO_XRS700X = DSA_TAG_PROTO_XRS700X_VALUE, DSA_TAG_PROTO_XRS700X = DSA_TAG_PROTO_XRS700X_VALUE,
DSA_TAG_PROTO_OCELOT_8021Q = DSA_TAG_PROTO_OCELOT_8021Q_VALUE, DSA_TAG_PROTO_OCELOT_8021Q = DSA_TAG_PROTO_OCELOT_8021Q_VALUE,
DSA_TAG_PROTO_SEVILLE = DSA_TAG_PROTO_SEVILLE_VALUE, DSA_TAG_PROTO_SEVILLE = DSA_TAG_PROTO_SEVILLE_VALUE,
DSA_TAG_PROTO_SJA1110 = DSA_TAG_PROTO_SJA1110_VALUE,
}; };
struct packet_type; struct packet_type;
...@@ -91,7 +93,8 @@ struct dsa_device_ops { ...@@ -91,7 +93,8 @@ struct dsa_device_ops {
* as regular on the master net device. * as regular on the master net device.
*/ */
bool (*filter)(const struct sk_buff *skb, struct net_device *dev); bool (*filter)(const struct sk_buff *skb, struct net_device *dev);
unsigned int overhead; unsigned int needed_headroom;
unsigned int needed_tailroom;
const char *name; const char *name;
enum dsa_tag_protocol proto; enum dsa_tag_protocol proto;
/* Some tagging protocols either mangle or shift the destination MAC /* Some tagging protocols either mangle or shift the destination MAC
...@@ -100,7 +103,6 @@ struct dsa_device_ops { ...@@ -100,7 +103,6 @@ struct dsa_device_ops {
* its RX filter. * its RX filter.
*/ */
bool promisc_on_master; bool promisc_on_master;
bool tail_tag;
}; };
/* This structure defines the control interfaces that are overlayed by the /* This structure defines the control interfaces that are overlayed by the
...@@ -926,7 +928,7 @@ static inline void dsa_tag_generic_flow_dissect(const struct sk_buff *skb, ...@@ -926,7 +928,7 @@ static inline void dsa_tag_generic_flow_dissect(const struct sk_buff *skb,
{ {
#if IS_ENABLED(CONFIG_NET_DSA) #if IS_ENABLED(CONFIG_NET_DSA)
const struct dsa_device_ops *ops = skb->dev->dsa_ptr->tag_ops; const struct dsa_device_ops *ops = skb->dev->dsa_ptr->tag_ops;
int tag_len = ops->overhead; int tag_len = ops->needed_headroom;
*offset = tag_len; *offset = tag_len;
*proto = ((__be16 *)skb->data)[(tag_len / 2) - 1]; *proto = ((__be16 *)skb->data)[(tag_len / 2) - 1];
......
...@@ -944,7 +944,7 @@ bool __skb_flow_dissect(const struct net *net, ...@@ -944,7 +944,7 @@ bool __skb_flow_dissect(const struct net *net,
ops = skb->dev->dsa_ptr->tag_ops; ops = skb->dev->dsa_ptr->tag_ops;
/* Tail taggers don't break flow dissection */ /* Tail taggers don't break flow dissection */
if (!ops->tail_tag) { if (!ops->needed_headroom) {
if (ops->flow_dissect) if (ops->flow_dissect)
ops->flow_dissect(skb, &proto, &offset); ops->flow_dissect(skb, &proto, &offset);
else else
......
...@@ -154,6 +154,11 @@ const struct dsa_device_ops *dsa_find_tagger_by_name(const char *buf); ...@@ -154,6 +154,11 @@ const struct dsa_device_ops *dsa_find_tagger_by_name(const char *buf);
bool dsa_schedule_work(struct work_struct *work); bool dsa_schedule_work(struct work_struct *work);
const char *dsa_tag_protocol_to_str(const struct dsa_device_ops *ops); const char *dsa_tag_protocol_to_str(const struct dsa_device_ops *ops);
static inline int dsa_tag_protocol_overhead(const struct dsa_device_ops *ops)
{
return ops->needed_headroom + ops->needed_tailroom;
}
/* master.c */ /* master.c */
int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp); int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp);
void dsa_master_teardown(struct net_device *dev); void dsa_master_teardown(struct net_device *dev);
......
...@@ -346,10 +346,12 @@ static struct lock_class_key dsa_master_addr_list_lock_key; ...@@ -346,10 +346,12 @@ static struct lock_class_key dsa_master_addr_list_lock_key;
int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp) int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
{ {
int mtu = ETH_DATA_LEN + cpu_dp->tag_ops->overhead; const struct dsa_device_ops *tag_ops = cpu_dp->tag_ops;
struct dsa_switch *ds = cpu_dp->ds; struct dsa_switch *ds = cpu_dp->ds;
struct device_link *consumer_link; struct device_link *consumer_link;
int ret; int mtu, ret;
mtu = ETH_DATA_LEN + dsa_tag_protocol_overhead(tag_ops);
/* The DSA master must use SET_NETDEV_DEV for this to work. */ /* The DSA master must use SET_NETDEV_DEV for this to work. */
consumer_link = device_link_add(ds->dev, dev->dev.parent, consumer_link = device_link_add(ds->dev, dev->dev.parent,
......
...@@ -1569,7 +1569,7 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu) ...@@ -1569,7 +1569,7 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu)
mtu_limit = min_t(int, master->max_mtu, dev->max_mtu); mtu_limit = min_t(int, master->max_mtu, dev->max_mtu);
old_master_mtu = master->mtu; old_master_mtu = master->mtu;
new_master_mtu = largest_mtu + cpu_dp->tag_ops->overhead; new_master_mtu = largest_mtu + dsa_tag_protocol_overhead(cpu_dp->tag_ops);
if (new_master_mtu > mtu_limit) if (new_master_mtu > mtu_limit)
return -ERANGE; return -ERANGE;
...@@ -1605,7 +1605,7 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu) ...@@ -1605,7 +1605,7 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu)
out_port_failed: out_port_failed:
if (new_master_mtu != old_master_mtu) if (new_master_mtu != old_master_mtu)
dsa_port_mtu_change(cpu_dp, old_master_mtu - dsa_port_mtu_change(cpu_dp, old_master_mtu -
cpu_dp->tag_ops->overhead, dsa_tag_protocol_overhead(cpu_dp->tag_ops),
true); true);
out_cpu_failed: out_cpu_failed:
if (new_master_mtu != old_master_mtu) if (new_master_mtu != old_master_mtu)
...@@ -1824,10 +1824,8 @@ void dsa_slave_setup_tagger(struct net_device *slave) ...@@ -1824,10 +1824,8 @@ void dsa_slave_setup_tagger(struct net_device *slave)
const struct dsa_port *cpu_dp = dp->cpu_dp; const struct dsa_port *cpu_dp = dp->cpu_dp;
struct net_device *master = cpu_dp->master; struct net_device *master = cpu_dp->master;
if (cpu_dp->tag_ops->tail_tag) slave->needed_headroom = cpu_dp->tag_ops->needed_headroom;
slave->needed_tailroom = cpu_dp->tag_ops->overhead; slave->needed_tailroom = cpu_dp->tag_ops->needed_tailroom;
else
slave->needed_headroom = cpu_dp->tag_ops->overhead;
/* Try to save one extra realloc later in the TX path (in the master) /* Try to save one extra realloc later in the TX path (in the master)
* by also inheriting the master's needed headroom and tailroom. * by also inheriting the master's needed headroom and tailroom.
* The 8021q driver also does this. * The 8021q driver also does this.
......
...@@ -471,4 +471,27 @@ struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, ...@@ -471,4 +471,27 @@ struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev,
} }
EXPORT_SYMBOL_GPL(dsa_8021q_xmit); EXPORT_SYMBOL_GPL(dsa_8021q_xmit);
void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id,
int *subvlan)
{
u16 vid, tci;
skb_push_rcsum(skb, ETH_HLEN);
if (skb_vlan_tag_present(skb)) {
tci = skb_vlan_tag_get(skb);
__vlan_hwaccel_clear_tag(skb);
} else {
__skb_vlan_pop(skb, &tci);
}
skb_pull_rcsum(skb, ETH_HLEN);
vid = tci & VLAN_VID_MASK;
*source_port = dsa_8021q_rx_source_port(vid);
*switch_id = dsa_8021q_rx_switch_id(vid);
*subvlan = dsa_8021q_rx_subvlan(vid);
skb->priority = (tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
}
EXPORT_SYMBOL_GPL(dsa_8021q_rcv);
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -85,7 +85,7 @@ static const struct dsa_device_ops ar9331_netdev_ops = { ...@@ -85,7 +85,7 @@ static const struct dsa_device_ops ar9331_netdev_ops = {
.proto = DSA_TAG_PROTO_AR9331, .proto = DSA_TAG_PROTO_AR9331,
.xmit = ar9331_tag_xmit, .xmit = ar9331_tag_xmit,
.rcv = ar9331_tag_rcv, .rcv = ar9331_tag_rcv,
.overhead = AR9331_HDR_LEN, .needed_headroom = AR9331_HDR_LEN,
}; };
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
......
...@@ -205,7 +205,7 @@ static const struct dsa_device_ops brcm_netdev_ops = { ...@@ -205,7 +205,7 @@ static const struct dsa_device_ops brcm_netdev_ops = {
.proto = DSA_TAG_PROTO_BRCM, .proto = DSA_TAG_PROTO_BRCM,
.xmit = brcm_tag_xmit, .xmit = brcm_tag_xmit,
.rcv = brcm_tag_rcv, .rcv = brcm_tag_rcv,
.overhead = BRCM_TAG_LEN, .needed_headroom = BRCM_TAG_LEN,
}; };
DSA_TAG_DRIVER(brcm_netdev_ops); DSA_TAG_DRIVER(brcm_netdev_ops);
...@@ -286,7 +286,7 @@ static const struct dsa_device_ops brcm_legacy_netdev_ops = { ...@@ -286,7 +286,7 @@ static const struct dsa_device_ops brcm_legacy_netdev_ops = {
.proto = DSA_TAG_PROTO_BRCM_LEGACY, .proto = DSA_TAG_PROTO_BRCM_LEGACY,
.xmit = brcm_leg_tag_xmit, .xmit = brcm_leg_tag_xmit,
.rcv = brcm_leg_tag_rcv, .rcv = brcm_leg_tag_rcv,
.overhead = BRCM_LEG_TAG_LEN, .needed_headroom = BRCM_LEG_TAG_LEN,
}; };
DSA_TAG_DRIVER(brcm_legacy_netdev_ops); DSA_TAG_DRIVER(brcm_legacy_netdev_ops);
...@@ -314,7 +314,7 @@ static const struct dsa_device_ops brcm_prepend_netdev_ops = { ...@@ -314,7 +314,7 @@ static const struct dsa_device_ops brcm_prepend_netdev_ops = {
.proto = DSA_TAG_PROTO_BRCM_PREPEND, .proto = DSA_TAG_PROTO_BRCM_PREPEND,
.xmit = brcm_tag_xmit_prepend, .xmit = brcm_tag_xmit_prepend,
.rcv = brcm_tag_rcv_prepend, .rcv = brcm_tag_rcv_prepend,
.overhead = BRCM_TAG_LEN, .needed_headroom = BRCM_TAG_LEN,
}; };
DSA_TAG_DRIVER(brcm_prepend_netdev_ops); DSA_TAG_DRIVER(brcm_prepend_netdev_ops);
......
...@@ -303,7 +303,7 @@ static const struct dsa_device_ops dsa_netdev_ops = { ...@@ -303,7 +303,7 @@ static const struct dsa_device_ops dsa_netdev_ops = {
.proto = DSA_TAG_PROTO_DSA, .proto = DSA_TAG_PROTO_DSA,
.xmit = dsa_xmit, .xmit = dsa_xmit,
.rcv = dsa_rcv, .rcv = dsa_rcv,
.overhead = DSA_HLEN, .needed_headroom = DSA_HLEN,
}; };
DSA_TAG_DRIVER(dsa_netdev_ops); DSA_TAG_DRIVER(dsa_netdev_ops);
...@@ -346,7 +346,7 @@ static const struct dsa_device_ops edsa_netdev_ops = { ...@@ -346,7 +346,7 @@ static const struct dsa_device_ops edsa_netdev_ops = {
.proto = DSA_TAG_PROTO_EDSA, .proto = DSA_TAG_PROTO_EDSA,
.xmit = edsa_xmit, .xmit = edsa_xmit,
.rcv = edsa_rcv, .rcv = edsa_rcv,
.overhead = EDSA_HLEN, .needed_headroom = EDSA_HLEN,
}; };
DSA_TAG_DRIVER(edsa_netdev_ops); DSA_TAG_DRIVER(edsa_netdev_ops);
......
...@@ -103,7 +103,7 @@ static const struct dsa_device_ops gswip_netdev_ops = { ...@@ -103,7 +103,7 @@ static const struct dsa_device_ops gswip_netdev_ops = {
.proto = DSA_TAG_PROTO_GSWIP, .proto = DSA_TAG_PROTO_GSWIP,
.xmit = gswip_tag_xmit, .xmit = gswip_tag_xmit,
.rcv = gswip_tag_rcv, .rcv = gswip_tag_rcv,
.overhead = GSWIP_RX_HEADER_LEN, .needed_headroom = GSWIP_RX_HEADER_LEN,
}; };
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -54,8 +54,7 @@ static const struct dsa_device_ops hellcreek_netdev_ops = { ...@@ -54,8 +54,7 @@ static const struct dsa_device_ops hellcreek_netdev_ops = {
.proto = DSA_TAG_PROTO_HELLCREEK, .proto = DSA_TAG_PROTO_HELLCREEK,
.xmit = hellcreek_xmit, .xmit = hellcreek_xmit,
.rcv = hellcreek_rcv, .rcv = hellcreek_rcv,
.overhead = HELLCREEK_TAG_LEN, .needed_tailroom = HELLCREEK_TAG_LEN,
.tail_tag = true,
}; };
MODULE_LICENSE("Dual MIT/GPL"); MODULE_LICENSE("Dual MIT/GPL");
......
...@@ -77,8 +77,7 @@ static const struct dsa_device_ops ksz8795_netdev_ops = { ...@@ -77,8 +77,7 @@ static const struct dsa_device_ops ksz8795_netdev_ops = {
.proto = DSA_TAG_PROTO_KSZ8795, .proto = DSA_TAG_PROTO_KSZ8795,
.xmit = ksz8795_xmit, .xmit = ksz8795_xmit,
.rcv = ksz8795_rcv, .rcv = ksz8795_rcv,
.overhead = KSZ_INGRESS_TAG_LEN, .needed_tailroom = KSZ_INGRESS_TAG_LEN,
.tail_tag = true,
}; };
DSA_TAG_DRIVER(ksz8795_netdev_ops); DSA_TAG_DRIVER(ksz8795_netdev_ops);
...@@ -149,8 +148,7 @@ static const struct dsa_device_ops ksz9477_netdev_ops = { ...@@ -149,8 +148,7 @@ static const struct dsa_device_ops ksz9477_netdev_ops = {
.proto = DSA_TAG_PROTO_KSZ9477, .proto = DSA_TAG_PROTO_KSZ9477,
.xmit = ksz9477_xmit, .xmit = ksz9477_xmit,
.rcv = ksz9477_rcv, .rcv = ksz9477_rcv,
.overhead = KSZ9477_INGRESS_TAG_LEN, .needed_tailroom = KSZ9477_INGRESS_TAG_LEN,
.tail_tag = true,
}; };
DSA_TAG_DRIVER(ksz9477_netdev_ops); DSA_TAG_DRIVER(ksz9477_netdev_ops);
...@@ -183,8 +181,7 @@ static const struct dsa_device_ops ksz9893_netdev_ops = { ...@@ -183,8 +181,7 @@ static const struct dsa_device_ops ksz9893_netdev_ops = {
.proto = DSA_TAG_PROTO_KSZ9893, .proto = DSA_TAG_PROTO_KSZ9893,
.xmit = ksz9893_xmit, .xmit = ksz9893_xmit,
.rcv = ksz9477_rcv, .rcv = ksz9477_rcv,
.overhead = KSZ_INGRESS_TAG_LEN, .needed_tailroom = KSZ_INGRESS_TAG_LEN,
.tail_tag = true,
}; };
DSA_TAG_DRIVER(ksz9893_netdev_ops); DSA_TAG_DRIVER(ksz9893_netdev_ops);
......
...@@ -125,7 +125,7 @@ static const struct dsa_device_ops lan9303_netdev_ops = { ...@@ -125,7 +125,7 @@ static const struct dsa_device_ops lan9303_netdev_ops = {
.proto = DSA_TAG_PROTO_LAN9303, .proto = DSA_TAG_PROTO_LAN9303,
.xmit = lan9303_xmit, .xmit = lan9303_xmit,
.rcv = lan9303_rcv, .rcv = lan9303_rcv,
.overhead = LAN9303_TAG_LEN, .needed_headroom = LAN9303_TAG_LEN,
}; };
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -102,7 +102,7 @@ static const struct dsa_device_ops mtk_netdev_ops = { ...@@ -102,7 +102,7 @@ static const struct dsa_device_ops mtk_netdev_ops = {
.proto = DSA_TAG_PROTO_MTK, .proto = DSA_TAG_PROTO_MTK,
.xmit = mtk_tag_xmit, .xmit = mtk_tag_xmit,
.rcv = mtk_tag_rcv, .rcv = mtk_tag_rcv,
.overhead = MTK_HDR_LEN, .needed_headroom = MTK_HDR_LEN,
}; };
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -143,7 +143,7 @@ static const struct dsa_device_ops ocelot_netdev_ops = { ...@@ -143,7 +143,7 @@ static const struct dsa_device_ops ocelot_netdev_ops = {
.proto = DSA_TAG_PROTO_OCELOT, .proto = DSA_TAG_PROTO_OCELOT,
.xmit = ocelot_xmit, .xmit = ocelot_xmit,
.rcv = ocelot_rcv, .rcv = ocelot_rcv,
.overhead = OCELOT_TOTAL_TAG_LEN, .needed_headroom = OCELOT_TOTAL_TAG_LEN,
.promisc_on_master = true, .promisc_on_master = true,
}; };
...@@ -155,7 +155,7 @@ static const struct dsa_device_ops seville_netdev_ops = { ...@@ -155,7 +155,7 @@ static const struct dsa_device_ops seville_netdev_ops = {
.proto = DSA_TAG_PROTO_SEVILLE, .proto = DSA_TAG_PROTO_SEVILLE,
.xmit = seville_xmit, .xmit = seville_xmit,
.rcv = ocelot_rcv, .rcv = ocelot_rcv,
.overhead = OCELOT_TOTAL_TAG_LEN, .needed_headroom = OCELOT_TOTAL_TAG_LEN,
.promisc_on_master = true, .promisc_on_master = true,
}; };
......
...@@ -41,29 +41,15 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, ...@@ -41,29 +41,15 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb,
struct net_device *netdev, struct net_device *netdev,
struct packet_type *pt) struct packet_type *pt)
{ {
int src_port, switch_id, qos_class; int src_port, switch_id, subvlan;
u16 vid, tci;
skb_push_rcsum(skb, ETH_HLEN); dsa_8021q_rcv(skb, &src_port, &switch_id, &subvlan);
if (skb_vlan_tag_present(skb)) {
tci = skb_vlan_tag_get(skb);
__vlan_hwaccel_clear_tag(skb);
} else {
__skb_vlan_pop(skb, &tci);
}
skb_pull_rcsum(skb, ETH_HLEN);
vid = tci & VLAN_VID_MASK;
src_port = dsa_8021q_rx_source_port(vid);
switch_id = dsa_8021q_rx_switch_id(vid);
qos_class = (tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
skb->dev = dsa_master_find_slave(netdev, switch_id, src_port); skb->dev = dsa_master_find_slave(netdev, switch_id, src_port);
if (!skb->dev) if (!skb->dev)
return NULL; return NULL;
skb->offload_fwd_mark = 1; skb->offload_fwd_mark = 1;
skb->priority = qos_class;
return skb; return skb;
} }
...@@ -73,7 +59,7 @@ static const struct dsa_device_ops ocelot_8021q_netdev_ops = { ...@@ -73,7 +59,7 @@ static const struct dsa_device_ops ocelot_8021q_netdev_ops = {
.proto = DSA_TAG_PROTO_OCELOT_8021Q, .proto = DSA_TAG_PROTO_OCELOT_8021Q,
.xmit = ocelot_xmit, .xmit = ocelot_xmit,
.rcv = ocelot_rcv, .rcv = ocelot_rcv,
.overhead = VLAN_HLEN, .needed_headroom = VLAN_HLEN,
.promisc_on_master = true, .promisc_on_master = true,
}; };
......
...@@ -91,7 +91,7 @@ static const struct dsa_device_ops qca_netdev_ops = { ...@@ -91,7 +91,7 @@ static const struct dsa_device_ops qca_netdev_ops = {
.proto = DSA_TAG_PROTO_QCA, .proto = DSA_TAG_PROTO_QCA,
.xmit = qca_tag_xmit, .xmit = qca_tag_xmit,
.rcv = qca_tag_rcv, .rcv = qca_tag_rcv,
.overhead = QCA_HDR_LEN, .needed_headroom = QCA_HDR_LEN,
}; };
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -124,7 +124,7 @@ static const struct dsa_device_ops rtl4a_netdev_ops = { ...@@ -124,7 +124,7 @@ static const struct dsa_device_ops rtl4a_netdev_ops = {
.proto = DSA_TAG_PROTO_RTL4_A, .proto = DSA_TAG_PROTO_RTL4_A,
.xmit = rtl4a_tag_xmit, .xmit = rtl4a_tag_xmit,
.rcv = rtl4a_tag_rcv, .rcv = rtl4a_tag_rcv,
.overhead = RTL4_A_HDR_LEN, .needed_headroom = RTL4_A_HDR_LEN,
}; };
module_dsa_tag_driver(rtl4a_netdev_ops); module_dsa_tag_driver(rtl4a_netdev_ops);
......
This diff is collapsed.
...@@ -55,8 +55,7 @@ static const struct dsa_device_ops trailer_netdev_ops = { ...@@ -55,8 +55,7 @@ static const struct dsa_device_ops trailer_netdev_ops = {
.proto = DSA_TAG_PROTO_TRAILER, .proto = DSA_TAG_PROTO_TRAILER,
.xmit = trailer_xmit, .xmit = trailer_xmit,
.rcv = trailer_rcv, .rcv = trailer_rcv,
.overhead = 4, .needed_tailroom = 4,
.tail_tag = true,
}; };
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -56,8 +56,7 @@ static const struct dsa_device_ops xrs700x_netdev_ops = { ...@@ -56,8 +56,7 @@ static const struct dsa_device_ops xrs700x_netdev_ops = {
.proto = DSA_TAG_PROTO_XRS700X, .proto = DSA_TAG_PROTO_XRS700X,
.xmit = xrs700x_xmit, .xmit = xrs700x_xmit,
.rcv = xrs700x_rcv, .rcv = xrs700x_rcv,
.overhead = 1, .needed_tailroom = 1,
.tail_tag = true,
}; };
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
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