linux/drivers/net/usb/cdc_ncm.c

/*
 * cdc_ncm.c
 *
 * Copyright (C) ST-Ericsson 2010-2012
 * Contact: Alexey Orishko <[email protected]>
 * Original author: Hans Petter Selasky <[email protected]>
 *
 * USB Host Driver for Network Control Model (NCM)
 * http://www.usb.org/developers/docs/devclass_docs/NCM10_012011.zip
 *
 * The NCM encoding, decoding and initialization logic
 * derives from FreeBSD 8.x. if_cdce.c and if_cdcereg.h
 *
 * This software is available to you under a choice of one of two
 * licenses. You may choose this file to be licensed under the terms
 * of the GNU General Public License (GPL) Version 2 or the 2-clause
 * BSD license listed below:
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/ctype.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/kstrtox.h>
#include <linux/workqueue.h>
#include <linux/mii.h>
#include <linux/crc32.h>
#include <linux/usb.h>
#include <linux/hrtimer.h>
#include <linux/atomic.h>
#include <linux/usb/usbnet.h>
#include <linux/usb/cdc.h>
#include <linux/usb/cdc_ncm.h>

#if IS_ENABLED(CONFIG_USB_NET_CDC_MBIM)
static bool prefer_mbim =;
#else
static bool prefer_mbim;
#endif
module_param(prefer_mbim, bool, 0644);
MODULE_PARM_DESC();

static void cdc_ncm_txpath_bh(struct tasklet_struct *t);
static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx);
static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *hr_timer);
static struct usb_driver cdc_ncm_driver;

struct cdc_ncm_stats {};

#define CDC_NCM_STAT(str, m)
#define CDC_NCM_SIMPLE_STAT(m)

static const struct cdc_ncm_stats cdc_ncm_gstrings_stats[] =;

#define CDC_NCM_LOW_MEM_MAX_CNT

static int cdc_ncm_get_sset_count(struct net_device __always_unused *netdev, int sset)
{}

static void cdc_ncm_get_ethtool_stats(struct net_device *netdev,
				    struct ethtool_stats __always_unused *stats,
				    u64 *data)
{}

static void cdc_ncm_get_strings(struct net_device __always_unused *netdev, u32 stringset, u8 *data)
{}

static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx);

static const struct ethtool_ops cdc_ncm_ethtool_ops =;

static u32 cdc_ncm_check_rx_max(struct usbnet *dev, u32 new_rx)
{}

static u32 cdc_ncm_check_tx_max(struct usbnet *dev, u32 new_tx)
{}

static ssize_t min_tx_pkt_show(struct device *d,
			       struct device_attribute *attr, char *buf)
{}

static ssize_t rx_max_show(struct device *d,
			   struct device_attribute *attr, char *buf)
{}

static ssize_t tx_max_show(struct device *d,
			   struct device_attribute *attr, char *buf)
{}

static ssize_t tx_timer_usecs_show(struct device *d,
				   struct device_attribute *attr, char *buf)
{}

static ssize_t min_tx_pkt_store(struct device *d,
				struct device_attribute *attr,
				const char *buf, size_t len)
{}

static ssize_t rx_max_store(struct device *d,
			    struct device_attribute *attr,
			    const char *buf, size_t len)
{}

static ssize_t tx_max_store(struct device *d,
			    struct device_attribute *attr,
			    const char *buf, size_t len)
{}

static ssize_t tx_timer_usecs_store(struct device *d,
				    struct device_attribute *attr,
				    const char *buf, size_t len)
{}

static DEVICE_ATTR_RW(min_tx_pkt);
static DEVICE_ATTR_RW(rx_max);
static DEVICE_ATTR_RW(tx_max);
static DEVICE_ATTR_RW(tx_timer_usecs);

static ssize_t ndp_to_end_show(struct device *d, struct device_attribute *attr, char *buf)
{}

static ssize_t ndp_to_end_store(struct device *d,  struct device_attribute *attr, const char *buf, size_t len)
{}
static DEVICE_ATTR_RW(ndp_to_end);

#define NCM_PARM_ATTR(name, format, tocpu)

NCM_PARM_ATTR();
NCM_PARM_ATTR();
NCM_PARM_ATTR();
NCM_PARM_ATTR();
NCM_PARM_ATTR();
NCM_PARM_ATTR();
NCM_PARM_ATTR();
NCM_PARM_ATTR();
NCM_PARM_ATTR();
NCM_PARM_ATTR();

static struct attribute *cdc_ncm_sysfs_attrs[] =;

static const struct attribute_group cdc_ncm_sysfs_attr_group =;

/* handle rx_max and tx_max changes */
static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)
{}

/* helpers for NCM and MBIM differences */
static u8 cdc_ncm_flags(struct usbnet *dev)
{}

static int cdc_ncm_eth_hlen(struct usbnet *dev)
{}

static u32 cdc_ncm_min_dgram_size(struct usbnet *dev)
{}

static u32 cdc_ncm_max_dgram_size(struct usbnet *dev)
{}

/* initial one-time device setup.  MUST be called with the data interface
 * in altsetting 0
 */
static int cdc_ncm_init(struct usbnet *dev)
{}

/* set a new max datagram size */
static void cdc_ncm_set_dgram_size(struct usbnet *dev, int new_size)
{}

static void cdc_ncm_fix_modulus(struct usbnet *dev)
{}

static int cdc_ncm_setup(struct usbnet *dev)
{}

static void
cdc_ncm_find_endpoints(struct usbnet *dev, struct usb_interface *intf)
{}

static void cdc_ncm_free(struct cdc_ncm_ctx *ctx)
{}

/* we need to override the usbnet change_mtu ndo for two reasons:
 *  - respect the negotiated maximum datagram size
 *  - avoid unwanted changes to rx and tx buffers
 */
int cdc_ncm_change_mtu(struct net_device *net, int new_mtu)
{}
EXPORT_SYMBOL_GPL();

static const struct net_device_ops cdc_ncm_netdev_ops =;

int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting, int drvflags)
{}
EXPORT_SYMBOL_GPL();

void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf)
{}
EXPORT_SYMBOL_GPL();

/* Return the number of the MBIM control interface altsetting iff it
 * is preferred and available,
 */
u8 cdc_ncm_select_altsetting(struct usb_interface *intf)
{}
EXPORT_SYMBOL_GPL();

static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf)
{}

static void cdc_ncm_align_tail(struct sk_buff *skb, size_t modulus, size_t remainder, size_t max)
{}

/* return a pointer to a valid struct usb_cdc_ncm_ndp16 of type sign, possibly
 * allocating a new one within skb
 */
static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb, __le32 sign, size_t reserve)
{}

static struct usb_cdc_ncm_ndp32 *cdc_ncm_ndp32(struct cdc_ncm_ctx *ctx, struct sk_buff *skb, __le32 sign, size_t reserve)
{}

struct sk_buff *
cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
{}
EXPORT_SYMBOL_GPL();

static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx)
{}

static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *timer)
{}

static void cdc_ncm_txpath_bh(struct tasklet_struct *t)
{}

struct sk_buff *
cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
{}
EXPORT_SYMBOL_GPL();

/* verify NTB header and return offset of first NDP, or negative error */
int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in)
{}
EXPORT_SYMBOL_GPL();

int cdc_ncm_rx_verify_nth32(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in)
{}
EXPORT_SYMBOL_GPL();

/* verify NDP header and return number of datagrams, or negative error */
int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset)
{}
EXPORT_SYMBOL_GPL();

/* verify NDP header and return number of datagrams, or negative error */
int cdc_ncm_rx_verify_ndp32(struct sk_buff *skb_in, int ndpoffset)
{}
EXPORT_SYMBOL_GPL();

int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
{}
EXPORT_SYMBOL_GPL();

static void
cdc_ncm_speed_change(struct usbnet *dev,
		     struct usb_cdc_speed_change *data)
{}

static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
{}

static const struct driver_info cdc_ncm_info =;

/* Same as cdc_ncm_info, but with FLAG_SEND_ZLP  */
static const struct driver_info cdc_ncm_zlp_info =;

/* Same as cdc_ncm_info, but with FLAG_SEND_ZLP */
static const struct driver_info apple_tethering_interface_info =;

/* Same as apple_tethering_interface_info, but without FLAG_LINK_INTR */
static const struct driver_info apple_private_interface_info =;

/* Same as cdc_ncm_info, but with FLAG_WWAN */
static const struct driver_info wwan_info =;

/* Same as wwan_info, but with FLAG_NOARP  */
static const struct driver_info wwan_noarp_info =;

static const struct usb_device_id cdc_devs[] =;
MODULE_DEVICE_TABLE(usb, cdc_devs);

static struct usb_driver cdc_ncm_driver =;

module_usb_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();