David Brownell | 2b3d942 | 2008-06-19 18:19:28 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * u_ether.h -- interface to USB gadget "ethernet link" utilities |
| 3 | * |
| 4 | * Copyright (C) 2003-2005,2008 David Brownell |
| 5 | * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger |
| 6 | * Copyright (C) 2008 Nokia Corporation |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #ifndef __U_ETHER_H |
| 24 | #define __U_ETHER_H |
| 25 | |
| 26 | #include <linux/err.h> |
| 27 | #include <linux/if_ether.h> |
| 28 | #include <linux/usb/composite.h> |
| 29 | #include <linux/usb/cdc.h> |
| 30 | |
| 31 | /* |
| 32 | * This represents the USB side of an "ethernet" link, managed by a USB |
| 33 | * function which provides control and (maybe) framing. Two functions |
| 34 | * in different configurations could share the same ethernet link/netdev. |
| 35 | * |
| 36 | * There is currently a limitation that one instance of this function |
| 37 | * may be present in any given configuration. |
| 38 | */ |
| 39 | struct gether { |
| 40 | struct usb_function func; |
| 41 | |
| 42 | /* updated by gether_{connect,disconnect} */ |
| 43 | struct eth_dev *ioport; |
| 44 | |
| 45 | /* endpoints handle full and/or high speeds */ |
| 46 | struct usb_ep *in_ep; |
| 47 | struct usb_ep *out_ep; |
| 48 | |
| 49 | /* descriptors match device speed at gether_connect() time */ |
| 50 | struct usb_endpoint_descriptor *in; |
| 51 | struct usb_endpoint_descriptor *out; |
| 52 | |
| 53 | bool is_zlp_ok; |
| 54 | |
| 55 | u16 cdc_filter; |
| 56 | |
| 57 | /* hooks for added framing, as needed for RNDIS and EEM. |
| 58 | * we currently don't support multiple frames per SKB. |
| 59 | */ |
| 60 | u32 header_len; |
| 61 | struct sk_buff *(*wrap)(struct sk_buff *skb); |
| 62 | int (*unwrap)(struct sk_buff *skb); |
| 63 | |
| 64 | /* called on network open/close */ |
| 65 | void (*open)(struct gether *); |
| 66 | void (*close)(struct gether *); |
| 67 | }; |
| 68 | |
| 69 | #define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \ |
| 70 | |USB_CDC_PACKET_TYPE_ALL_MULTICAST \ |
| 71 | |USB_CDC_PACKET_TYPE_PROMISCUOUS \ |
| 72 | |USB_CDC_PACKET_TYPE_DIRECTED) |
| 73 | |
| 74 | |
| 75 | /* netdev setup/teardown as directed by the gadget driver */ |
| 76 | int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN]); |
| 77 | void gether_cleanup(void); |
| 78 | |
| 79 | /* connect/disconnect is handled by individual functions */ |
| 80 | struct net_device *gether_connect(struct gether *); |
| 81 | void gether_disconnect(struct gether *); |
| 82 | |
| 83 | #endif /* __U_ETHER_H */ |