linux/drivers/net/usb/cdc_mbim.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2012  Smith Micro Software, Inc.
 * Copyright (c) 2012  Bjørn Mork <[email protected]>
 *
 * This driver is based on and reuse most of cdc_ncm, which is
 * Copyright (C) ST-Ericsson 2010-2012
 */

#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/ethtool.h>
#include <linux/if_vlan.h>
#include <linux/ip.h>
#include <linux/mii.h>
#include <linux/usb.h>
#include <linux/usb/cdc.h>
#include <linux/usb/usbnet.h>
#include <linux/usb/cdc-wdm.h>
#include <linux/usb/cdc_ncm.h>
#include <net/ipv6.h>
#include <net/addrconf.h>
#include <net/ipv6_stubs.h>
#include <net/ndisc.h>

/* alternative VLAN for IP session 0 if not untagged */
#define MBIM_IPS0_VID

/* driver specific data - must match cdc_ncm usage */
struct cdc_mbim_state {};

/* flags for the cdc_mbim_state.flags field */
enum cdc_mbim_flags {};

/* using a counter to merge subdriver requests with our own into a combined state */
static int cdc_mbim_manage_power(struct usbnet *dev, int on)
{}

static int cdc_mbim_wdm_manage_power(struct usb_interface *intf, int status)
{}

static int cdc_mbim_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
{}

static int cdc_mbim_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid)
{}

static const struct net_device_ops cdc_mbim_netdev_ops =;

/* Change the control interface altsetting and update the .driver_info
 * pointer if the matching entry after changing class codes points to
 * a different struct
 */
static int cdc_mbim_set_ctrlalt(struct usbnet *dev, struct usb_interface *intf, u8 alt)
{}

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

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

/* verify that the ethernet protocol is IPv4 or IPv6 */
static bool is_ip_proto(__be16 proto)
{}

static struct sk_buff *cdc_mbim_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
{}

/* Some devices are known to send Neighbor Solicitation messages and
 * require Neighbor Advertisement replies.  The IPv6 core will not
 * respond since IFF_NOARP is set, so we must handle them ourselves.
 */
static void do_neigh_solicit(struct usbnet *dev, u8 *buf, u16 tci)
{}

static bool is_neigh_solicit(u8 *buf, size_t len)
{}


static struct sk_buff *cdc_mbim_process_dgram(struct usbnet *dev, u8 *buf, size_t len, u16 tci)
{}

static int cdc_mbim_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
{}

static int cdc_mbim_suspend(struct usb_interface *intf, pm_message_t message)
{}

static int cdc_mbim_resume(struct usb_interface *intf)
{}

static const struct driver_info cdc_mbim_info =;

/* MBIM and NCM devices should not need a ZLP after NTBs with
 * dwNtbOutMaxSize length. Nevertheless, a number of devices from
 * different vendor IDs will fail unless we send ZLPs, forcing us
 * to make this the default.
 *
 * This default may cause a performance penalty for spec conforming
 * devices wanting to take advantage of optimizations possible without
 * ZLPs.  A whitelist is added in an attempt to avoid this for devices
 * known to conform to the MBIM specification.
 *
 * All known devices supporting NCM compatibility mode are also
 * conforming to the NCM and MBIM specifications. For this reason, the
 * NCM subclass entry is also in the ZLP whitelist.
 */
static const struct driver_info cdc_mbim_info_zlp =;

/* The spefication explicitly allows NDPs to be placed anywhere in the
 * frame, but some devices fail unless the NDP is placed after the IP
 * packets.  Using the CDC_NCM_FLAG_NDP_TO_END flags to force this
 * behaviour.
 *
 * Note: The current implementation of this feature restricts each NTB
 * to a single NDP, implying that multiplexed sessions cannot share an
 * NTB. This might affect performance for multiplexed sessions.
 */
static const struct driver_info cdc_mbim_info_ndp_to_end =;

/* Some modems (e.g. Telit LE922A6) do not work properly with altsetting
 * toggle done in cdc_ncm_bind_common. CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE
 * flag is used to avoid this procedure.
 */
static const struct driver_info cdc_mbim_info_avoid_altsetting_toggle =;

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

static struct usb_driver cdc_mbim_driver =;
module_usb_driver();

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