/* * This represents the USB side of an "ethernet" link, managed by a USB * function which provides control and (maybe) framing. Two functions * in different configurations could share the same ethernet link/netdev, * using different host interaction models. * * There is a current limitation that only one instance of this link may * be present in any given configuration. When that's a problem, network * layer facilities can be used to package multiple logical links on this * single "physical" one.
*/ struct gether { struct usb_function func;
/* updated by gether_{connect,disconnect} */ struct eth_dev *ioport;
/* endpoints handle full and/or high speeds */ struct usb_ep *in_ep; struct usb_ep *out_ep;
bool is_zlp_ok;
u16 cdc_filter;
/* hooks for added framing, as needed for RNDIS and EEM. */
u32 header_len; /* NCM requires fixed size bundles */ bool is_fixed;
u32 fixed_out_len;
u32 fixed_in_len; bool supports_multi_frame; struct sk_buff *(*wrap)(struct gether *port, struct sk_buff *skb); int (*unwrap)(struct gether *port, struct sk_buff *skb, struct sk_buff_head *list);
/* called on network open/close */ void (*open)(struct gether *); void (*close)(struct gether *); bool is_suspend;
};
/* variant of gether_setup that allows customizing network device name */ struct eth_dev *gether_setup_name(struct usb_gadget *g, constchar *dev_addr, constchar *host_addr,
u8 ethaddr[ETH_ALEN], unsigned qmult, constchar *netname);
/* netdev setup/teardown as directed by the gadget driver */ /* gether_setup - initialize one ethernet-over-usb link * @g: gadget to associated with these links * @ethaddr: NULL, or a buffer in which the ethernet address of the * host side of the link is recorded * Context: may sleep * * This sets up the single network link that may be exported by a * gadget driver using this framework. The link layer addresses are * set up using module parameters. * * Returns a eth_dev pointer on success, or an ERR_PTR on failure
*/ staticinlinestruct eth_dev *gether_setup(struct usb_gadget *g, constchar *dev_addr, constchar *host_addr,
u8 ethaddr[ETH_ALEN], unsigned qmult)
{ return gether_setup_name(g, dev_addr, host_addr, ethaddr, qmult, "usb");
}
/* * variant of gether_setup_default that allows customizing * network device name
*/ struct net_device *gether_setup_name_default(constchar *netname);
/* * gether_register_netdev - register the net device * @net: net device to register * * Registers the net device associated with this ethernet-over-usb link *
*/ int gether_register_netdev(struct net_device *net);
/* gether_setup_default - initialize one ethernet-over-usb link * Context: may sleep * * This sets up the single network link that may be exported by a * gadget driver using this framework. The link layer addresses * are set to random values. * * Returns negative errno, or zero on success
*/ staticinlinestruct net_device *gether_setup_default(void)
{ return gether_setup_name_default("usb");
}
/** * gether_set_gadget - initialize one ethernet-over-usb link with a gadget * @net: device representing this link * @g: the gadget to initialize with * * This associates one ethernet-over-usb link with a gadget.
*/ void gether_set_gadget(struct net_device *net, struct usb_gadget *g);
/** * gether_set_dev_addr - initialize an ethernet-over-usb link with eth address * @net: device representing this link * @dev_addr: eth address of this device * * This sets the device-side Ethernet address of this ethernet-over-usb link * if dev_addr is correct. * Returns negative errno if the new address is incorrect.
*/ int gether_set_dev_addr(struct net_device *net, constchar *dev_addr);
/** * gether_get_dev_addr - get an ethernet-over-usb link eth address * @net: device representing this link * @dev_addr: place to store device's eth address * @len: length of the @dev_addr buffer * * This gets the device-side Ethernet address of this ethernet-over-usb link. * Returns zero on success, else negative errno.
*/ int gether_get_dev_addr(struct net_device *net, char *dev_addr, int len);
/** * gether_set_host_addr - initialize an ethernet-over-usb link with host address * @net: device representing this link * @host_addr: eth address of the host * * This sets the host-side Ethernet address of this ethernet-over-usb link * if host_addr is correct. * Returns negative errno if the new address is incorrect.
*/ int gether_set_host_addr(struct net_device *net, constchar *host_addr);
/** * gether_get_host_addr - get an ethernet-over-usb link host address * @net: device representing this link * @host_addr: place to store eth address of the host * @len: length of the @host_addr buffer * * This gets the host-side Ethernet address of this ethernet-over-usb link. * Returns zero on success, else negative errno.
*/ int gether_get_host_addr(struct net_device *net, char *host_addr, int len);
/** * gether_get_host_addr_cdc - get an ethernet-over-usb link host address * @net: device representing this link * @host_addr: place to store eth address of the host * @len: length of the @host_addr buffer * * This gets the CDC formatted host-side Ethernet address of this * ethernet-over-usb link. * Returns zero on success, else negative errno.
*/ int gether_get_host_addr_cdc(struct net_device *net, char *host_addr, int len);
/** * gether_get_host_addr_u8 - get an ethernet-over-usb link host address * @net: device representing this link * @host_mac: place to store the eth address of the host * * This gets the binary formatted host-side Ethernet address of this * ethernet-over-usb link.
*/ void gether_get_host_addr_u8(struct net_device *net, u8 host_mac[ETH_ALEN]);
/** * gether_set_qmult - initialize an ethernet-over-usb link with a multiplier * @net: device representing this link * @qmult: queue multiplier * * This sets the queue length multiplier of this ethernet-over-usb link. * For higher speeds use longer queues.
*/ void gether_set_qmult(struct net_device *net, unsigned qmult);
/** * gether_get_qmult - get an ethernet-over-usb link multiplier * @net: device representing this link * * This gets the queue length multiplier of this ethernet-over-usb link.
*/ unsigned gether_get_qmult(struct net_device *net);
/** * gether_get_ifname - get an ethernet-over-usb link interface name * @net: device representing this link * @name: place to store the interface name * @len: length of the @name buffer * * This gets the interface name of this ethernet-over-usb link. * Returns zero on success, else negative errno.
*/ int gether_get_ifname(struct net_device *net, char *name, int len);
/** * gether_set_ifname - set an ethernet-over-usb link interface name * @net: device representing this link * @name: new interface name * @len: length of @name * * This sets the interface name of this ethernet-over-usb link. * A single terminating newline, if any, is ignored. * Returns zero on success, else negative errno.
*/ int gether_set_ifname(struct net_device *net, constchar *name, int len);
/* connect/disconnect is handled by individual functions */ struct net_device *gether_connect(struct gether *); void gether_disconnect(struct gether *);
/* Some controllers can't support CDC Ethernet (ECM) ... */ staticinlinebool can_support_ecm(struct usb_gadget *gadget)
{ if (!gadget_is_altset_supported(gadget)) returnfalse;
/* Everything else is *presumably* fine ... but this is a bit * chancy, so be **CERTAIN** there are no hardware issues with * your controller. Add it above if it can't handle CDC.
*/ returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.