Messages in this thread Patch in this message | | | From | Alexander Lobakin <> | Subject | [PATCH RFC net-next 09/19] net: dsa: tag_gswip: split out common tag accessors | Date | Mon, 30 Dec 2019 17:30:17 +0300 |
| |
...to reuse them in GRO callbacks.
Signed-off-by: Alexander Lobakin <alobakin@dlink.ru> --- net/dsa/tag_gswip.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/net/dsa/tag_gswip.c b/net/dsa/tag_gswip.c index d37289540ef3..e7b36de27fd8 100644 --- a/net/dsa/tag_gswip.c +++ b/net/dsa/tag_gswip.c @@ -55,6 +55,16 @@ /* Byte 7 */ #define GSWIP_RX_SPPID(byte_7) FIELD_GET(GENMASK(6, 4), byte_7) +static inline int gswip_tag_source_port(const u8 *data) +{ + return GSWIP_RX_SPPID(*(data - ETH_HLEN + 7)); +} + +static inline __be16 gswip_tag_encap_proto(const u8 *data) +{ + return *(__be16 *)(data + 6); +} + static struct sk_buff *gswip_tag_xmit(struct sk_buff *skb, struct net_device *dev) { @@ -85,7 +95,7 @@ static struct sk_buff *gswip_tag_rcv(struct sk_buff *skb, return NULL; /* Get source port information */ - port = GSWIP_RX_SPPID(*(skb->data - ETH_HLEN + 7)); + port = gswip_tag_source_port(skb->data); skb->dev = dsa_master_find_slave(dev, 0, port); if (!skb->dev) @@ -101,7 +111,7 @@ static void gswip_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, int *offset) { *offset = GSWIP_RX_HEADER_LEN; - *proto = *(__be16 *)(skb->data + 6); + *proto = gswip_tag_encap_proto(skb->data); } static const struct dsa_device_ops gswip_netdev_ops = { -- 2.24.1
| |