mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
net: hsr: generate supervision frame without HSR/PRP tag
For a switch to offload insertion of HSR/PRP tags, frames must not be sent to the CPU facing switch port with a tag. Generate supervision frames (eth type ETH_P_PRP) without HSR v1 (ETH_P_HSR)/PRP tag and rely on create_tagged_frame which inserts it later. This will allow skipping the tag insertion for all outgoing frames in the future which is required for HSR v1/PRP tag insertions to be offloaded. HSR v0 supervision frames always contain tag information so insertion of the tag can't be offloaded. IEC 62439-3 Ed.2.0 (HSR v1) specifically notes that this was changed since v0 to allow offloading. Signed-off-by: George McCollister <george.mccollister@gmail.com> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Tested-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
f8a7e0145d
commit
78be9217c4
@@ -230,7 +230,7 @@ static const struct header_ops hsr_header_ops = {
|
|||||||
.parse = eth_header_parse,
|
.parse = eth_header_parse,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct sk_buff *hsr_init_skb(struct hsr_port *master, u16 proto)
|
static struct sk_buff *hsr_init_skb(struct hsr_port *master)
|
||||||
{
|
{
|
||||||
struct hsr_priv *hsr = master->hsr;
|
struct hsr_priv *hsr = master->hsr;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
@@ -242,8 +242,7 @@ static struct sk_buff *hsr_init_skb(struct hsr_port *master, u16 proto)
|
|||||||
* being, for PRP it is a trailer and for HSR it is a
|
* being, for PRP it is a trailer and for HSR it is a
|
||||||
* header
|
* header
|
||||||
*/
|
*/
|
||||||
skb = dev_alloc_skb(sizeof(struct hsr_tag) +
|
skb = dev_alloc_skb(sizeof(struct hsr_sup_tag) +
|
||||||
sizeof(struct hsr_sup_tag) +
|
|
||||||
sizeof(struct hsr_sup_payload) + hlen + tlen);
|
sizeof(struct hsr_sup_payload) + hlen + tlen);
|
||||||
|
|
||||||
if (!skb)
|
if (!skb)
|
||||||
@@ -251,10 +250,9 @@ static struct sk_buff *hsr_init_skb(struct hsr_port *master, u16 proto)
|
|||||||
|
|
||||||
skb_reserve(skb, hlen);
|
skb_reserve(skb, hlen);
|
||||||
skb->dev = master->dev;
|
skb->dev = master->dev;
|
||||||
skb->protocol = htons(proto);
|
|
||||||
skb->priority = TC_PRIO_CONTROL;
|
skb->priority = TC_PRIO_CONTROL;
|
||||||
|
|
||||||
if (dev_hard_header(skb, skb->dev, proto,
|
if (dev_hard_header(skb, skb->dev, ETH_P_PRP,
|
||||||
hsr->sup_multicast_addr,
|
hsr->sup_multicast_addr,
|
||||||
skb->dev->dev_addr, skb->len) <= 0)
|
skb->dev->dev_addr, skb->len) <= 0)
|
||||||
goto out;
|
goto out;
|
||||||
@@ -275,12 +273,10 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
|
|||||||
{
|
{
|
||||||
struct hsr_priv *hsr = master->hsr;
|
struct hsr_priv *hsr = master->hsr;
|
||||||
__u8 type = HSR_TLV_LIFE_CHECK;
|
__u8 type = HSR_TLV_LIFE_CHECK;
|
||||||
struct hsr_tag *hsr_tag = NULL;
|
|
||||||
struct hsr_sup_payload *hsr_sp;
|
struct hsr_sup_payload *hsr_sp;
|
||||||
struct hsr_sup_tag *hsr_stag;
|
struct hsr_sup_tag *hsr_stag;
|
||||||
unsigned long irqflags;
|
unsigned long irqflags;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
u16 proto;
|
|
||||||
|
|
||||||
*interval = msecs_to_jiffies(HSR_LIFE_CHECK_INTERVAL);
|
*interval = msecs_to_jiffies(HSR_LIFE_CHECK_INTERVAL);
|
||||||
if (hsr->announce_count < 3 && hsr->prot_version == 0) {
|
if (hsr->announce_count < 3 && hsr->prot_version == 0) {
|
||||||
@@ -289,23 +285,12 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
|
|||||||
hsr->announce_count++;
|
hsr->announce_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hsr->prot_version)
|
skb = hsr_init_skb(master);
|
||||||
proto = ETH_P_PRP;
|
|
||||||
else
|
|
||||||
proto = ETH_P_HSR;
|
|
||||||
|
|
||||||
skb = hsr_init_skb(master, proto);
|
|
||||||
if (!skb) {
|
if (!skb) {
|
||||||
WARN_ONCE(1, "HSR: Could not send supervision frame\n");
|
WARN_ONCE(1, "HSR: Could not send supervision frame\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hsr->prot_version > 0) {
|
|
||||||
hsr_tag = skb_put(skb, sizeof(struct hsr_tag));
|
|
||||||
hsr_tag->encap_proto = htons(ETH_P_PRP);
|
|
||||||
set_hsr_tag_LSDU_size(hsr_tag, HSR_V1_SUP_LSDUSIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
hsr_stag = skb_put(skb, sizeof(struct hsr_sup_tag));
|
hsr_stag = skb_put(skb, sizeof(struct hsr_sup_tag));
|
||||||
set_hsr_stag_path(hsr_stag, (hsr->prot_version ? 0x0 : 0xf));
|
set_hsr_stag_path(hsr_stag, (hsr->prot_version ? 0x0 : 0xf));
|
||||||
set_hsr_stag_HSR_ver(hsr_stag, hsr->prot_version);
|
set_hsr_stag_HSR_ver(hsr_stag, hsr->prot_version);
|
||||||
@@ -315,8 +300,6 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
|
|||||||
if (hsr->prot_version > 0) {
|
if (hsr->prot_version > 0) {
|
||||||
hsr_stag->sequence_nr = htons(hsr->sup_sequence_nr);
|
hsr_stag->sequence_nr = htons(hsr->sup_sequence_nr);
|
||||||
hsr->sup_sequence_nr++;
|
hsr->sup_sequence_nr++;
|
||||||
hsr_tag->sequence_nr = htons(hsr->sequence_nr);
|
|
||||||
hsr->sequence_nr++;
|
|
||||||
} else {
|
} else {
|
||||||
hsr_stag->sequence_nr = htons(hsr->sequence_nr);
|
hsr_stag->sequence_nr = htons(hsr->sequence_nr);
|
||||||
hsr->sequence_nr++;
|
hsr->sequence_nr++;
|
||||||
@@ -332,7 +315,7 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
|
|||||||
hsr_sp = skb_put(skb, sizeof(struct hsr_sup_payload));
|
hsr_sp = skb_put(skb, sizeof(struct hsr_sup_payload));
|
||||||
ether_addr_copy(hsr_sp->macaddress_A, master->dev->dev_addr);
|
ether_addr_copy(hsr_sp->macaddress_A, master->dev->dev_addr);
|
||||||
|
|
||||||
if (skb_put_padto(skb, ETH_ZLEN + HSR_HLEN))
|
if (skb_put_padto(skb, ETH_ZLEN))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hsr_forward_skb(skb, master);
|
hsr_forward_skb(skb, master);
|
||||||
@@ -348,10 +331,8 @@ static void send_prp_supervision_frame(struct hsr_port *master,
|
|||||||
struct hsr_sup_tag *hsr_stag;
|
struct hsr_sup_tag *hsr_stag;
|
||||||
unsigned long irqflags;
|
unsigned long irqflags;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
struct prp_rct *rct;
|
|
||||||
u8 *tail;
|
|
||||||
|
|
||||||
skb = hsr_init_skb(master, ETH_P_PRP);
|
skb = hsr_init_skb(master);
|
||||||
if (!skb) {
|
if (!skb) {
|
||||||
WARN_ONCE(1, "PRP: Could not send supervision frame\n");
|
WARN_ONCE(1, "PRP: Could not send supervision frame\n");
|
||||||
return;
|
return;
|
||||||
@@ -373,17 +354,11 @@ static void send_prp_supervision_frame(struct hsr_port *master,
|
|||||||
hsr_sp = skb_put(skb, sizeof(struct hsr_sup_payload));
|
hsr_sp = skb_put(skb, sizeof(struct hsr_sup_payload));
|
||||||
ether_addr_copy(hsr_sp->macaddress_A, master->dev->dev_addr);
|
ether_addr_copy(hsr_sp->macaddress_A, master->dev->dev_addr);
|
||||||
|
|
||||||
if (skb_put_padto(skb, ETH_ZLEN + HSR_HLEN)) {
|
if (skb_put_padto(skb, ETH_ZLEN)) {
|
||||||
spin_unlock_irqrestore(&master->hsr->seqnr_lock, irqflags);
|
spin_unlock_irqrestore(&master->hsr->seqnr_lock, irqflags);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tail = skb_tail_pointer(skb) - HSR_HLEN;
|
|
||||||
rct = (struct prp_rct *)tail;
|
|
||||||
rct->PRP_suffix = htons(ETH_P_PRP);
|
|
||||||
set_prp_LSDU_size(rct, HSR_V1_SUP_LSDUSIZE);
|
|
||||||
rct->sequence_nr = htons(hsr->sequence_nr);
|
|
||||||
hsr->sequence_nr++;
|
|
||||||
spin_unlock_irqrestore(&master->hsr->seqnr_lock, irqflags);
|
spin_unlock_irqrestore(&master->hsr->seqnr_lock, irqflags);
|
||||||
|
|
||||||
hsr_forward_skb(skb, master);
|
hsr_forward_skb(skb, master);
|
||||||
|
@@ -186,6 +186,7 @@ static struct sk_buff *prp_fill_rct(struct sk_buff *skb,
|
|||||||
set_prp_LSDU_size(trailer, lsdu_size);
|
set_prp_LSDU_size(trailer, lsdu_size);
|
||||||
trailer->sequence_nr = htons(frame->sequence_nr);
|
trailer->sequence_nr = htons(frame->sequence_nr);
|
||||||
trailer->PRP_suffix = htons(ETH_P_PRP);
|
trailer->PRP_suffix = htons(ETH_P_PRP);
|
||||||
|
skb->protocol = eth_hdr(skb)->h_proto;
|
||||||
|
|
||||||
return skb;
|
return skb;
|
||||||
}
|
}
|
||||||
@@ -226,6 +227,7 @@ static struct sk_buff *hsr_fill_tag(struct sk_buff *skb,
|
|||||||
hsr_ethhdr->hsr_tag.encap_proto = hsr_ethhdr->ethhdr.h_proto;
|
hsr_ethhdr->hsr_tag.encap_proto = hsr_ethhdr->ethhdr.h_proto;
|
||||||
hsr_ethhdr->ethhdr.h_proto = htons(proto_version ?
|
hsr_ethhdr->ethhdr.h_proto = htons(proto_version ?
|
||||||
ETH_P_HSR : ETH_P_PRP);
|
ETH_P_HSR : ETH_P_PRP);
|
||||||
|
skb->protocol = hsr_ethhdr->ethhdr.h_proto;
|
||||||
|
|
||||||
return skb;
|
return skb;
|
||||||
}
|
}
|
||||||
@@ -454,7 +456,11 @@ static void handle_std_frame(struct sk_buff *skb,
|
|||||||
void hsr_fill_frame_info(__be16 proto, struct sk_buff *skb,
|
void hsr_fill_frame_info(__be16 proto, struct sk_buff *skb,
|
||||||
struct hsr_frame_info *frame)
|
struct hsr_frame_info *frame)
|
||||||
{
|
{
|
||||||
if (proto == htons(ETH_P_PRP) ||
|
struct hsr_port *port = frame->port_rcv;
|
||||||
|
struct hsr_priv *hsr = port->hsr;
|
||||||
|
|
||||||
|
/* HSRv0 supervisory frames double as a tag so treat them as tagged. */
|
||||||
|
if ((!hsr->prot_version && proto == htons(ETH_P_PRP)) ||
|
||||||
proto == htons(ETH_P_HSR)) {
|
proto == htons(ETH_P_HSR)) {
|
||||||
/* HSR tagged frame :- Data or Supervision */
|
/* HSR tagged frame :- Data or Supervision */
|
||||||
frame->skb_std = NULL;
|
frame->skb_std = NULL;
|
||||||
|
Reference in New Issue
Block a user