blob: b3c281be017ed79d65221108fb0aaada2622e040 [file] [log] [blame]
Ofir Cohen7e942b52012-07-26 13:54:14 +03001/*
2 * u_qc_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 * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef __U_QC_ETHER_H
23#define __U_QC_ETHER_H
24
25#include <linux/err.h>
26#include <linux/if_ether.h>
27#include <linux/usb/composite.h>
28#include <linux/usb/cdc.h>
29
30#include "gadget_chips.h"
31
32
33/*
34 * This represents the USB side of an "ethernet" link, managed by a USB
35 * function which provides control and (maybe) framing. Two functions
36 * in different configurations could share the same ethernet link/netdev,
37 * using different host interaction models.
38 *
39 * There is a current limitation that only one instance of this link may
40 * be present in any given configuration. When that's a problem, network
41 * layer facilities can be used to package multiple logical links on this
42 * single "physical" one.
43 *
44 * This function is based on Ethernet-over-USB link layer utilities and
45 * contains MSM specific implementation.
46 */
47
48struct qc_gether {
49 struct usb_function func;
50
51 /* updated by gether_{connect,disconnect} */
52 struct eth_qc_dev *ioport;
53
54 /* endpoints handle full and/or high speeds */
55 struct usb_ep *in_ep;
56 struct usb_ep *out_ep;
57
58 bool is_zlp_ok;
59
60 u16 cdc_filter;
61
62 /* hooks for added framing, as needed for RNDIS and EEM. */
63 u32 header_len;
64 /* NCM requires fixed size bundles */
65 bool is_fixed;
66 u32 fixed_out_len;
67 u32 fixed_in_len;
68 struct sk_buff *(*wrap)(struct qc_gether *port,
69 struct sk_buff *skb);
70 int (*unwrap)(struct qc_gether *port,
71 struct sk_buff *skb,
72 struct sk_buff_head *list);
73
74 /* called on network open/close */
75 void (*open)(struct qc_gether *);
76 void (*close)(struct qc_gether *);
77};
78
79/* netdev setup/teardown as directed by the gadget driver */
80int gether_qc_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN]);
81void gether_qc_cleanup(void);
82/* variant of gether_setup that allows customizing network device name */
83int gether_qc_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN],
84 const char *netname);
85
86/* connect/disconnect is handled by individual functions */
87struct net_device *gether_qc_connect(struct qc_gether *);
88void gether_qc_disconnect(struct qc_gether *);
89
90/* each configuration may bind one instance of an ethernet link */
91int ecm_qc_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]);
92
93int
94rndis_qc_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
95 u32 vendorID, const char *manufacturer,
96 u8 maxPktPerXfer);
97#endif /* __U_QC_ETHER_H */