Commit 121c33b0 authored by Murali Karicheri's avatar Murali Karicheri Committed by David S. Miller

net: hsr: introduce common code for skb initialization

As a preparatory patch to introduce PRP protocol support in the
driver, refactor the skb init code to a separate function.
Signed-off-by: default avatarMurali Karicheri <m-karicheri2@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8f4c0e01
...@@ -230,15 +230,11 @@ static const struct header_ops hsr_header_ops = { ...@@ -230,15 +230,11 @@ static const struct header_ops hsr_header_ops = {
.parse = eth_header_parse, .parse = eth_header_parse,
}; };
static void send_hsr_supervision_frame(struct hsr_port *master, static struct sk_buff *hsr_init_skb(struct hsr_port *master, u8 hsr_ver)
u8 type, u8 hsr_ver)
{ {
struct hsr_priv *hsr = master->hsr;
struct sk_buff *skb; struct sk_buff *skb;
int hlen, tlen; int hlen, tlen;
struct hsr_tag *hsr_tag;
struct hsr_sup_tag *hsr_stag;
struct hsr_sup_payload *hsr_sp;
unsigned long irqflags;
hlen = LL_RESERVED_SPACE(master->dev); hlen = LL_RESERVED_SPACE(master->dev);
tlen = master->dev->needed_tailroom; tlen = master->dev->needed_tailroom;
...@@ -247,22 +243,44 @@ static void send_hsr_supervision_frame(struct hsr_port *master, ...@@ -247,22 +243,44 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
sizeof(struct hsr_sup_payload) + hlen + tlen); sizeof(struct hsr_sup_payload) + hlen + tlen);
if (!skb) if (!skb)
return; return skb;
skb_reserve(skb, hlen); skb_reserve(skb, hlen);
skb->dev = master->dev; skb->dev = master->dev;
skb->protocol = htons(hsr_ver ? ETH_P_HSR : ETH_P_PRP); skb->protocol = htons(hsr_ver ? ETH_P_HSR : ETH_P_PRP);
skb->priority = TC_PRIO_CONTROL; skb->priority = TC_PRIO_CONTROL;
if (dev_hard_header(skb, skb->dev, (hsr_ver ? ETH_P_HSR : ETH_P_PRP), if (dev_hard_header(skb, skb->dev, (hsr_ver ? ETH_P_HSR : ETH_P_PRP),
master->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;
skb_reset_mac_header(skb); skb_reset_mac_header(skb);
skb_reset_network_header(skb); skb_reset_network_header(skb);
skb_reset_transport_header(skb); skb_reset_transport_header(skb);
return skb;
out:
kfree_skb(skb);
return NULL;
}
static void send_hsr_supervision_frame(struct hsr_port *master,
u8 type, u8 hsr_ver)
{
struct hsr_sup_payload *hsr_sp;
struct hsr_sup_tag *hsr_stag;
struct hsr_tag *hsr_tag;
unsigned long irqflags;
struct sk_buff *skb;
skb = hsr_init_skb(master, hsr_ver);
if (!skb) {
WARN_ONCE(1, "HSR: Could not send supervision frame\n");
return;
}
if (hsr_ver > 0) { if (hsr_ver > 0) {
hsr_tag = skb_put(skb, sizeof(struct hsr_tag)); hsr_tag = skb_put(skb, sizeof(struct hsr_tag));
hsr_tag->encap_proto = htons(ETH_P_PRP); hsr_tag->encap_proto = htons(ETH_P_PRP);
...@@ -299,11 +317,8 @@ static void send_hsr_supervision_frame(struct hsr_port *master, ...@@ -299,11 +317,8 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
return; return;
hsr_forward_skb(skb, master); hsr_forward_skb(skb, master);
return;
out: return;
WARN_ONCE(1, "HSR: Could not send supervision frame\n");
kfree_skb(skb);
} }
/* Announce (supervision frame) timer function /* Announce (supervision frame) timer function
......
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