Linux 4.16.11
[linux/fpc-iii.git] / drivers / net / wireless / mediatek / mt7601u / util.c
blob7c1787c1ddcdbd73ee093144d3b108e5a608d280
1 /*
2 * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include "mt7601u.h"
16 void mt76_remove_hdr_pad(struct sk_buff *skb)
18 int len = ieee80211_get_hdrlen_from_skb(skb);
20 memmove(skb->data + 2, skb->data, len);
21 skb_pull(skb, 2);
24 int mt76_insert_hdr_pad(struct sk_buff *skb)
26 int len = ieee80211_get_hdrlen_from_skb(skb);
27 int ret;
29 if (len % 4 == 0)
30 return 0;
32 ret = skb_cow(skb, 2);
33 if (ret)
34 return ret;
36 skb_push(skb, 2);
37 memmove(skb->data, skb->data + 2, len);
39 skb->data[len] = 0;
40 skb->data[len + 1] = 0;
41 return 0;