wireguard-tools: add tunlink option for hostroute
[openwrt/openwrt.git] / target / linux / ar71xx / files / drivers / net / ethernet / atheros / ag71xx / ag71xx_ar8216.c
1 /*
2 * Atheros AR71xx built-in ethernet mac driver
3 * Special support for the Atheros ar8216 switch chip
4 *
5 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
6 *
7 * Based on Atheros' AG7100 driver
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
12 */
13
14 #include "ag71xx.h"
15
16 #define AR8216_PACKET_TYPE_MASK 0xf
17 #define AR8216_PACKET_TYPE_NORMAL 0
18
19 #define AR8216_HEADER_LEN 2
20
21 void ag71xx_add_ar8216_header(struct ag71xx *ag, struct sk_buff *skb)
22 {
23 skb_push(skb, AR8216_HEADER_LEN);
24 skb->data[0] = 0x10;
25 skb->data[1] = 0x80;
26 }
27
28 int ag71xx_remove_ar8216_header(struct ag71xx *ag, struct sk_buff *skb,
29 int pktlen)
30 {
31 u8 type;
32
33 type = skb->data[1] & AR8216_PACKET_TYPE_MASK;
34 switch (type) {
35 case AR8216_PACKET_TYPE_NORMAL:
36 break;
37
38 default:
39 return -EINVAL;
40 }
41
42 skb_pull(skb, AR8216_HEADER_LEN);
43 return 0;
44 }