net/ethtool/netlink.h

Source file repositories/reference/linux-study-clean/net/ethtool/netlink.h

File Facts

System
Linux kernel
Corpus path
net/ethtool/netlink.h
Extension
.h
Size
22700 bytes
Lines
529
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

struct ethnl_req_info {
	struct net_device	*dev;
	netdevice_tracker	dev_tracker;
	u32			flags;
	u32			phy_index;
};

static inline void ethnl_parse_header_dev_put(struct ethnl_req_info *req_info)
{
	netdev_put(req_info->dev, &req_info->dev_tracker);
}

/**
 * ethnl_req_get_phydev() - Gets the phy_device targeted by this request,
 *			    if any.
 * @req_info:	The ethnl request to get the phy from.
 * @tb:		The netlink attributes array, for error reporting.
 * @header:	The netlink header index, used for error reporting.
 * @extack:	The netlink extended ACK, for error reporting.
 *
 * If a phy_device is returned the caller must hold rtnl_lock when calling
 * this function, and until it's done interacting with the returned phy_device.
 * IOW caller must hold rtnl_lock unless they know netdev has no phy_device.
 *
 * Return: A phy_device pointer corresponding either to the passed phy_index
 *	   if one is provided. If not, the phy_device attached to the
 *	   net_device targeted by this request is returned. If there's no
 *	   targeted net_device, or no phy_device is attached, NULL is
 *	   returned. If the provided phy_index is invalid, an error pointer
 *	   is returned.
 */
struct phy_device *ethnl_req_get_phydev(const struct ethnl_req_info *req_info,
					struct nlattr **tb, unsigned int header,
					struct netlink_ext_ack *extack);

/**
 * struct ethnl_reply_data - base type of reply data for GET requests
 * @dev:       device for current reply message; in single shot requests it is
 *             equal to &ethnl_req_info.dev; in dumps it's different for each
 *             reply message
 *
 * This is a common base for request specific structures holding data for
 * kernel reply message. These always embed struct ethnl_reply_data at zero
 * offset.
 */
struct ethnl_reply_data {
	struct net_device		*dev;
};

int ethnl_ops_begin(struct net_device *dev);
void ethnl_ops_complete(struct net_device *dev);

enum ethnl_sock_type {
	ETHTOOL_SOCK_TYPE_MODULE_FW_FLASH,
};

struct ethnl_sock_priv {
	struct net *net;
	u32 portid;
	enum ethnl_sock_type type;
};

int ethnl_sock_priv_set(struct sk_buff *skb, struct net *net, u32 portid,
			enum ethnl_sock_type type);

/**
 * struct ethnl_request_ops - unified handling of GET and SET requests
 * @request_cmd:      command id for request (GET)
 * @reply_cmd:        command id for reply (GET_REPLY)
 * @hdr_attr:         attribute type for request header
 * @req_info_size:    size of request info
 * @reply_data_size:  size of reply data
 * @allow_nodev_do:
 *	Allow non-dump request with no device identification.
 *	Note that locks (rtnl_lock etc.) are only taken if device is set.
 * @set_ntf_cmd:      notification to generate on changes (SET)
 * @parse_request:
 *	Parse request except common header (struct ethnl_req_info). Common
 *	header is already filled on entry, the rest up to @repdata_offset
 *	is zero initialized. This callback should only modify type specific
 *	request info by parsed attributes from request message.
 *	Called for both GET and SET. Information parsed for SET will
 *	be conveyed to the req_info used during NTF generation.
 * @prepare_data:
 *	Retrieve and prepare data needed to compose a reply message. Calls to
 *	ethtool_ops handlers are limited to this callback. Common reply data
 *	(struct ethnl_reply_data) is filled on entry, type specific part after
 *	it is zero initialized. This callback should only modify the type
 *	specific part of reply data. Device identification from struct
 *	ethnl_reply_data is to be used as for dump requests, it iterates

Annotation

Implementation Notes