1/* 2 * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org> 3 * 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 7 * 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. 12 */ 13 14#include "mt7601u.h" 15 16void mt76_remove_hdr_pad(struct sk_buff *skb) 17{ 18 int len = ieee80211_get_hdrlen_from_skb(skb); 19 20 memmove(skb->data + 2, skb->data, len); 21 skb_pull(skb, 2); 22} 23 24int mt76_insert_hdr_pad(struct sk_buff *skb) 25{ 26 int len = ieee80211_get_hdrlen_from_skb(skb); 27 int ret; 28 29 if (len % 4 == 0) 30 return 0; 31 32 ret = skb_cow(skb, 2); 33 if (ret) 34 return ret; 35 36 skb_push(skb, 2); 37 memmove(skb->data, skb->data + 2, len); 38 39 skb->data[len] = 0; 40 skb->data[len + 1] = 0; 41 return 0; 42} 43