net: dsa: ksz: Check return value
[platform/kernel/linux-rpi.git] / net / dsa / tag_mtk.c
index f9b2966..415d8ec 100644 (file)
@@ -41,10 +41,10 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb,
        default:
                xmit_tpid = MTK_HDR_XMIT_UNTAGGED;
                skb_push(skb, MTK_HDR_LEN);
-               memmove(skb->data, skb->data + MTK_HDR_LEN, 2 * ETH_ALEN);
+               dsa_alloc_etype_header(skb, MTK_HDR_LEN);
        }
 
-       mtk_tag = skb->data + 2 * ETH_ALEN;
+       mtk_tag = dsa_etype_header_pos_tx(skb);
 
        /* Mark tag attribute on special tag insertion to notify hardware
         * whether that's a combined special tag with 802.1Q header.
@@ -61,8 +61,7 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb,
        return skb;
 }
 
-static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev,
-                                  struct packet_type *pt)
+static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev)
 {
        u16 hdr;
        int port;
@@ -71,19 +70,13 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev,
        if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN)))
                return NULL;
 
-       /* The MTK header is added by the switch between src addr
-        * and ethertype at this point, skb->data points to 2 bytes
-        * after src addr so header should be 2 bytes right before.
-        */
-       phdr = (__be16 *)(skb->data - 2);
+       phdr = dsa_etype_header_pos_rx(skb);
        hdr = ntohs(*phdr);
 
        /* Remove MTK tag and recalculate checksum. */
        skb_pull_rcsum(skb, MTK_HDR_LEN);
 
-       memmove(skb->data - ETH_HLEN,
-               skb->data - ETH_HLEN - MTK_HDR_LEN,
-               2 * ETH_ALEN);
+       dsa_strip_etype_header(skb, MTK_HDR_LEN);
 
        /* Get source port information */
        port = (hdr & MTK_HDR_RECV_SOURCE_PORT_MASK);
@@ -92,7 +85,7 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev,
        if (!skb->dev)
                return NULL;
 
-       skb->offload_fwd_mark = 1;
+       dsa_default_offload_fwd_mark(skb);
 
        return skb;
 }
@@ -102,7 +95,7 @@ static const struct dsa_device_ops mtk_netdev_ops = {
        .proto          = DSA_TAG_PROTO_MTK,
        .xmit           = mtk_tag_xmit,
        .rcv            = mtk_tag_rcv,
-       .overhead       = MTK_HDR_LEN,
+       .needed_headroom = MTK_HDR_LEN,
 };
 
 MODULE_LICENSE("GPL");