blob: 25562da36f9da5de566294b4abbf7a943763dc58 [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
Amit Blayf9b352b2013-03-04 15:01:40 +02007 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Ofir Cohen7e942b52012-07-26 13:54:14 +03008 *
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} */
Amit Blayf9b352b2013-03-04 15:01:40 +020052 struct eth_qc_dev *ioport;
Ofir Cohen7e942b52012-07-26 13:54:14 +030053
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;
Amit Blayf9b352b2013-03-04 15:01:40 +020064
Ofir Cohen7e942b52012-07-26 13:54:14 +030065 struct sk_buff *(*wrap)(struct qc_gether *port,
66 struct sk_buff *skb);
67 int (*unwrap)(struct qc_gether *port,
68 struct sk_buff *skb,
69 struct sk_buff_head *list);
70
71 /* called on network open/close */
72 void (*open)(struct qc_gether *);
73 void (*close)(struct qc_gether *);
74};
75
76/* netdev setup/teardown as directed by the gadget driver */
77int gether_qc_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN]);
Amit Blayd6d690a2012-10-16 13:37:42 +020078void gether_qc_cleanup_name(const char *netname);
Ofir Cohen7e942b52012-07-26 13:54:14 +030079/* variant of gether_setup that allows customizing network device name */
80int gether_qc_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN],
81 const char *netname);
82
83/* connect/disconnect is handled by individual functions */
Amit Blayd6d690a2012-10-16 13:37:42 +020084struct net_device *gether_qc_connect_name(struct qc_gether *link,
85 const char *netname);
86void gether_qc_disconnect_name(struct qc_gether *link, const char *netname);
Ofir Cohen7e942b52012-07-26 13:54:14 +030087
88/* each configuration may bind one instance of an ethernet link */
Amit Blayf9b352b2013-03-04 15:01:40 +020089int ecm_qc_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
90 char *xport_name);
Ofir Cohen7e942b52012-07-26 13:54:14 +030091
92int
93rndis_qc_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
94 u32 vendorID, const char *manufacturer,
95 u8 maxPktPerXfer);
Amit Blayf9b352b2013-03-04 15:01:40 +020096
97void gether_qc_get_macs(u8 dev_mac[ETH_ALEN], u8 host_mac[ETH_ALEN]);
98
Ofir Cohen7e942b52012-07-26 13:54:14 +030099#endif /* __U_QC_ETHER_H */