This documentation is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For more details see the file COPYING in the source distribution of Linux.
Table of Contents
Table of Contents
enum sock_type — Socket types
enum sock_type {
SOCK_STREAM,
SOCK_DGRAM,
SOCK_RAW,
SOCK_RDM,
SOCK_SEQPACKET,
SOCK_DCCP,
SOCK_PACKET
}; stream (connection) socket
datagram (conn.less) socket
raw socket
reliably-delivered message
sequential packet socket
Datagram Congestion Control Protocol socket
linux specific way of getting packets at the dev level. For writing rarp and other similar things on the user level.
struct skb_shared_hwtstamps — hardware time stamps
struct skb_shared_hwtstamps {
ktime_t hwtstamp;
ktime_t syststamp;
}; hardware time stamp transformed into duration since arbitrary point in time
hwtstamp transformed to system time base
Software time stamps generated by ktime_get_real are stored in
skb->tstamp. The relation between the different kinds of time
syststamp and tstamp can be compared against each other in arbitrary combinations. The accuracy of a syststamp/tstamp/“syststamp from other device” comparison is limited by the accuracy of the transformation into system time base. This depends on the device driver and its underlying hardware.
hwtstamps can only be compared against other hwtstamps from the same device.
This structure is attached to packets as part of the
skb_shared_info. Use skb_hwtstamps to get a pointer.
struct sk_buff — socket buffer
struct sk_buff {
struct sk_buff * next;
struct sk_buff * prev;
ktime_t tstamp;
struct sock * sk;
struct net_device * dev;
char cb[48];
unsigned long _skb_refdst;
#ifdef CONFIG_XFRM
struct sec_path * sp;
#endif
unsigned int len;
unsigned int data_len;
__u16 mac_len;
__u16 hdr_len;
union {unnamed_union};
__u16 vlan_tci;
sk_buff_data_t transport_header;
sk_buff_data_t network_header;
sk_buff_data_t mac_header;
sk_buff_data_t tail;
sk_buff_data_t end;
unsigned char * head;
unsigned char * data;
unsigned int truesize;
atomic_t users;
}; Next buffer in list
Previous buffer in list
Time we arrived
Socket we are owned by
Device we arrived on/are leaving by
Control buffer. Free for use by every layer. Put private vars here
destination entry (with norefcount bit)
the security path, used for xfrm
Length of actual data
Data length
Length of link layer header
writable header length of cloned skb
anonymous
vlan tag control information
Transport layer header
Network layer header
Link layer header
Tail pointer
End pointer
Head of buffer
Data head pointer
Buffer size
User count - see {datagram,tcp}.c
skb_dst — returns skb dst_entry
struct dst_entry * skb_dst ( | skb); |
const struct sk_buff * skb;skb_dst_set — sets skb dst
void skb_dst_set ( | skb, | |
dst); |
struct sk_buff * skb;struct dst_entry * dst;skb_dst_is_noref — Test if skb dst isn't refcounted
bool skb_dst_is_noref ( | skb); |
const struct sk_buff * skb;skb_queue_empty — check if a queue is empty
int skb_queue_empty ( | list); |
const struct sk_buff_head * list;skb_queue_is_last — check if skb is the last entry in the queue
bool skb_queue_is_last ( | list, | |
skb); |
const struct sk_buff_head * list;const struct sk_buff * skb;skb_queue_is_first — check if skb is the first entry in the queue
bool skb_queue_is_first ( | list, | |
skb); |
const struct sk_buff_head * list;const struct sk_buff * skb;skb_queue_next — return the next packet in the queue
struct sk_buff * skb_queue_next ( | list, | |
skb); |
const struct sk_buff_head * list;const struct sk_buff * skb;skb_queue_prev — return the prev packet in the queue
struct sk_buff * skb_queue_prev ( | list, | |
skb); |
const struct sk_buff_head * list;const struct sk_buff * skb;skb_header_cloned — is the header a clone
int skb_header_cloned ( | skb); |
const struct sk_buff * skb;skb_header_release — release reference to header
void skb_header_release ( | skb); |
struct sk_buff * skb;skb_share_check — check if buffer is shared and if so clone it
struct sk_buff * skb_share_check ( | skb, | |
pri); |
struct sk_buff * skb;gfp_t pri;If the buffer is shared the buffer is cloned and the old copy drops a reference. A new clone with a single reference is returned. If the buffer is not shared the original buffer is returned. When being called from interrupt status or with spinlocks held pri must be GFP_ATOMIC.
NULL is returned on a memory allocation failure.
skb_unshare — make a copy of a shared buffer
struct sk_buff * skb_unshare ( | skb, | |
pri); |
struct sk_buff * skb;gfp_t pri;
If the socket buffer is a clone then this function creates a new
copy of the data, drops a reference count on the old copy and returns
the new copy with the reference count at 1. If the buffer is not a clone
the original buffer is returned. When called with a spinlock held or
from interrupt state pri must be GFP_ATOMIC
NULL is returned on a memory allocation failure.
skb_peek — peek at the head of an sk_buff_head
struct sk_buff * skb_peek ( | list_); |
struct sk_buff_head * list_;Peek an sk_buff. Unlike most other operations you _MUST_ be careful with this one. A peek leaves the buffer on the list and someone else may run off with it. You must hold the appropriate locks or have a private queue to do this.
Returns NULL for an empty list or a pointer to the head element.
The reference count is not incremented and the reference is therefore
volatile. Use with caution.
skb_peek_tail — peek at the tail of an sk_buff_head
struct sk_buff * skb_peek_tail ( | list_); |
struct sk_buff_head * list_;Peek an sk_buff. Unlike most other operations you _MUST_ be careful with this one. A peek leaves the buffer on the list and someone else may run off with it. You must hold the appropriate locks or have a private queue to do this.
Returns NULL for an empty list or a pointer to the tail element.
The reference count is not incremented and the reference is therefore
volatile. Use with caution.
skb_queue_len — get queue length
__u32 skb_queue_len ( | list_); |
const struct sk_buff_head * list_;__skb_queue_head_init — initialize non-spinlock portions of sk_buff_head
void __skb_queue_head_init ( | list); |
struct sk_buff_head * list;This initializes only the list and queue length aspects of an sk_buff_head object. This allows to initialize the list aspects of an sk_buff_head without reinitializing things like the spinlock. It can also be used for on-stack sk_buff_head objects where the spinlock is known to not be used.
skb_queue_splice — join two skb lists, this is designed for stacks
void skb_queue_splice ( | list, | |
head); |
const struct sk_buff_head * list;struct sk_buff_head * head;skb_queue_splice_init — join two skb lists and reinitialise the emptied list
void skb_queue_splice_init ( | list, | |
head); |
struct sk_buff_head * list;struct sk_buff_head * head;skb_queue_splice_tail — join two skb lists, each list being a queue
void skb_queue_splice_tail ( | list, | |
head); |
const struct sk_buff_head * list;struct sk_buff_head * head;skb_queue_splice_tail_init — join two skb lists and reinitialise the emptied list
void skb_queue_splice_tail_init ( | list, | |
head); |
struct sk_buff_head * list;struct sk_buff_head * head;__skb_queue_after — queue a buffer at the list head
void __skb_queue_after ( | list, | |
| prev, | ||
newsk); |
struct sk_buff_head * list;struct sk_buff * prev;struct sk_buff * newsk;skb_headroom — bytes at buffer head
unsigned int skb_headroom ( | skb); |
const struct sk_buff * skb;skb_reserve — adjust headroom
void skb_reserve ( | skb, | |
len); |
struct sk_buff * skb;int len;pskb_trim_unique — remove end from a paged unique (not cloned) buffer
void pskb_trim_unique ( | skb, | |
len); |
struct sk_buff * skb;unsigned int len;__dev_alloc_skb — allocate an skbuff for receiving
struct sk_buff * __dev_alloc_skb ( | length, | |
gfp_mask); |
unsigned int length;gfp_t gfp_mask;Allocate a new sk_buff and assign it a usage count of one. The buffer has unspecified headroom built in. Users should allocate the headroom they think they need without accounting for the built in space. The built in space is used for optimisations.
NULL is returned if there is no free memory.
netdev_alloc_skb — allocate an skbuff for rx on a specific device
struct sk_buff * netdev_alloc_skb ( | dev, | |
length); |
struct net_device * dev;unsigned int length;Allocate a new sk_buff and assign it a usage count of one. The buffer has unspecified headroom built in. Users should allocate the headroom they think they need without accounting for the built in space. The built in space is used for optimisations.
NULL is returned if there is no free memory. Although this function
allocates memory it can be called from an interrupt.
__netdev_alloc_page — allocate a page for ps-rx on a specific device
struct page * __netdev_alloc_page ( | dev, | |
gfp_mask); |
struct net_device * dev;gfp_t gfp_mask;netdev_alloc_page — allocate a page for ps-rx on a specific device
struct page * netdev_alloc_page ( | dev); |
struct net_device * dev;skb_clone_writable — is the header of a clone writable
int skb_clone_writable ( | skb, | |
len); |
struct sk_buff * skb;unsigned int len;skb_cow — copy header of skb when it is required
int skb_cow ( | skb, | |
headroom); |
struct sk_buff * skb;unsigned int headroom;skb_cow_head — skb_cow but only making the head writable
int skb_cow_head ( | skb, | |
headroom); |
struct sk_buff * skb;unsigned int headroom;skb_padto — pad an skbuff up to a minimal size
int skb_padto ( | skb, | |
len); |
struct sk_buff * skb;unsigned int len;skb_linearize — convert paged skb to linear one
int skb_linearize ( | skb); |
struct sk_buff * skb;skb_linearize_cow — make sure skb is linear and writable
int skb_linearize_cow ( | skb); |
struct sk_buff * skb;skb_postpull_rcsum — update checksum for received skb after pull
void skb_postpull_rcsum ( | skb, | |
| start, | ||
len); |
struct sk_buff * skb;const void * start;unsigned int len;pskb_trim_rcsum — trim received skb and update checksum
int pskb_trim_rcsum ( | skb, | |
len); |
struct sk_buff * skb;unsigned int len;skb_get_timestamp — get timestamp from a skb
void skb_get_timestamp ( | skb, | |
stamp); |
const struct sk_buff * skb;struct timeval * stamp;skb_complete_tx_timestamp — deliver cloned skb with tx timestamps
void skb_complete_tx_timestamp ( | skb, | |
hwtstamps); |
struct sk_buff * skb;struct skb_shared_hwtstamps * hwtstamps;skb_tx_timestamp — Driver hook for transmit timestamping
void skb_tx_timestamp ( | skb); |
struct sk_buff * skb;skb_checksum_complete — Calculate checksum of an entire packet
__sum16 skb_checksum_complete ( | skb); |
struct sk_buff * skb;This function calculates the checksum over the entire packet plus the value of skb->csum. The latter can be used to supply the checksum of a pseudo header as used by TCP/UDP. It returns the checksum.
For protocols that contain complete checksums such as ICMP/TCP/UDP, this function can be used to verify that checksum on received packets. In that case the function should return zero if the checksum is correct. In particular, this function will return zero if skb->ip_summed is CHECKSUM_UNNECESSARY which indicates that the hardware has already verified the correctness of the checksum.
skb_checksum_none_assert — make sure skb ip_summed is CHECKSUM_NONE
void skb_checksum_none_assert ( | skb); |
struct sk_buff * skb;struct sock_common — minimal network layer representation of sockets
struct sock_common {
__be32 skc_daddr;
__be32 skc_rcv_saddr;
union {unnamed_union};
int skc_tx_queue_mapping;
atomic_t skc_refcnt;
}; struct sock — network layer representation of sockets
struct sock {
struct sock_common __sk_common;
#define sk_node __sk_common.skc_node
#define sk_nulls_node __sk_common.skc_nulls_node
#define sk_refcnt __sk_common.skc_refcnt
#define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping
#define sk_dontcopy_begin __sk_common.skc_dontcopy_begin
#define sk_dontcopy_end __sk_common.skc_dontcopy_end
#define sk_hash __sk_common.skc_hash
#define sk_family __sk_common.skc_family
#define sk_state __sk_common.skc_state
#define sk_reuse __sk_common.skc_reuse
#define sk_bound_dev_if __sk_common.skc_bound_dev_if
#define sk_bind_node __sk_common.skc_bind_node
#define sk_prot __sk_common.skc_prot
#define sk_net __sk_common.skc_net
socket_lock_t sk_lock;
struct sk_buff_head sk_receive_queue;
struct sk_backlog;
#define sk_rmem_alloc sk_backlog.rmem_alloc
int sk_forward_alloc;
#ifdef CONFIG_RPS
__u32 sk_rxhash;
#endif
atomic_t sk_drops;
int sk_rcvbuf;
struct sk_filter __rcu * sk_filter;
struct socket_wq __rcu * sk_wq;
#ifdef CONFIG_NET_DMA
struct sk_buff_head sk_async_wait_queue;
#endif
#ifdef CONFIG_XFRM
struct xfrm_policy * sk_policy[2];
#endif
unsigned long sk_flags;
struct dst_entry * sk_dst_cache;
spinlock_t sk_dst_lock;
atomic_t sk_wmem_alloc;
atomic_t sk_omem_alloc;
int sk_sndbuf;
struct sk_buff_head sk_write_queue;
unsigned int sk_shutdown:2;
unsigned int sk_no_check:2;
unsigned int sk_userlocks:4;
unsigned int sk_protocol:8;
unsigned int sk_type:16;
int sk_wmem_queued;
gfp_t sk_allocation;
int sk_route_caps;
int sk_route_nocaps;
int sk_gso_type;
unsigned int sk_gso_max_size;
int sk_rcvlowat;
unsigned long sk_lingertime;
struct sk_buff_head sk_error_queue;
struct proto * sk_prot_creator;
rwlock_t sk_callback_lock;
int sk_err;
int sk_err_soft;
unsigned short sk_ack_backlog;
unsigned short sk_max_ack_backlog;
__u32 sk_priority;
struct pid * sk_peer_pid;
const struct cred * sk_peer_cred;
long sk_rcvtimeo;
long sk_sndtimeo;
void * sk_protinfo;
struct timer_list sk_timer;
ktime_t sk_stamp;
struct socket * sk_socket;
void * sk_user_data;
struct page * sk_sndmsg_page;
struct sk_buff * sk_send_head;
__u32 sk_sndmsg_off;
int sk_write_pending;
#ifdef CONFIG_SECURITY
void * sk_security;
#endif
__u32 sk_mark;
u32 sk_classid;
void (* sk_state_change) (struct sock *sk);
void (* sk_data_ready) (struct sock *sk, int bytes);
void (* sk_write_space) (struct sock *sk);
void (* sk_error_report) (struct sock *sk);
int (* sk_backlog_rcv) (struct sock *sk,struct sk_buff *skb);
void (* sk_destruct) (struct sock *sk);
}; shared layout with inet_timewait_sock
synchronizer
incoming packets
always used with the per-socket spinlock held
space allocated forward
flow hash received from netif layer
raw/udp drops counter
size of receive buffer in bytes
socket filtering instructions
sock wait queue and async head
DMA copied packets
flow policy
SO_LINGER (l_onoff), SO_BROADCAST, SO_KEEPALIVE,
SO_OOBINLINE settings, SO_TIMESTAMPING settings
destination cache
destination cache lock
transmit queue bytes committed
"o“ is ”option“ or ”other"
size of send buffer in bytes
Packet sending queue
mask of SEND_SHUTDOWN and/or RCV_SHUTDOWN
SO_NO_CHECK setting, wether or not checkup packets
SO_SNDBUF and SO_RCVBUF settings
which protocol this socket belongs in this network family
socket type (SOCK_STREAM, etc)
persistent queue size
allocation mode
route capabilities (e.g. NETIF_F_TSO)
forbidden route capabilities (e.g NETIF_F_GSO_MASK)
GSO type (e.g. SKB_GSO_TCPV4)
Maximum GSO segment size to build
SO_RCVLOWAT setting
SO_LINGER l_linger setting
rarely used
sk_prot of original sock creator (see ipv6_setsockopt, IPV6_ADDRFORM for instance)
used with the callbacks in the end of this struct
last error
errors that don't cause failure but are the cause of a persistent failure not just 'timed out'
current listen backlog
listen backlog set in listen
SO_PRIORITY setting
struct pid for this socket's peer
SO_PEERCRED setting
SO_RCVTIMEO setting
SO_SNDTIMEO setting
private area, net family specific, when not using slab
sock cleanup timer
time stamp of last packet received
Identd and reporting IO signals
RPC layer private data
cached page for sendmsg
front of stuff to transmit
cached offset for sendmsg
a write to stream socket waits to start
used by security modules
generic packet mark
this socket's cgroup classid
callback to indicate change in the state of the sock
callback to indicate there is data to be processed
callback to indicate there is bf sending space available
callback to indicate errors (e.g. MSG_ERRQUEUE)
callback to process the backlog
called at sock freeing time, i.e. when all refcnt == 0
unlock_sock_fast — complement of lock_sock_fast
void unlock_sock_fast ( | sk, | |
slow); |
struct sock * sk;bool slow;sk_filter_release — release a socket filter
void sk_filter_release ( | fp); |
struct sk_filter * fp;sk_wmem_alloc_get — returns write allocations
int sk_wmem_alloc_get ( | sk); |
const struct sock * sk;sk_rmem_alloc_get — returns read allocations
int sk_rmem_alloc_get ( | sk); |
const struct sock * sk;sk_has_allocations — check if allocations are outstanding
int sk_has_allocations ( | sk); |
const struct sock * sk;wq_has_sleeper — check if there are any waiting processes
bool wq_has_sleeper ( | wq); |
struct socket_wq * wq;Returns true if socket_wq has waiting processes
The purpose of the wq_has_sleeper and sock_poll_wait is to wrap the memory barrier call. They were added due to the race found within the tcp code.
CPU1 CPU2
sys_select receive packet
... ...
__add_wait_queue update tp->rcv_nxt
... ...
tp->rcv_nxt check sock_def_readable
... {
schedule rcu_read_lock;
wq = rcu_dereference(sk->sk_wq);
if (wq && waitqueue_active(wq->wait))
wake_up_interruptible(wq->wait)
...
}
The race for tcp fires when the __add_wait_queue changes done by CPU1 stay in its cache, and so does the tp->rcv_nxt update on CPU2 side. The CPU1 could then endup calling schedule and sleep forever if there are no more data on the socket.
sock_poll_wait — place memory barrier behind the poll_wait call.
void sock_poll_wait ( | filp, | |
| wait_address, | ||
p); |
struct file * filp;wait_queue_head_t * wait_address;poll_table * p;sk_eat_skb — Release a skb if it is no longer needed
void sk_eat_skb ( | sk, | |
| skb, | ||
copied_early); |
struct sock * sk;struct sk_buff * skb;int copied_early;sockfd_lookup — Go from a file number to its socket slot
struct socket * sockfd_lookup ( | fd, | |
err); |
int fd;int * err;The file handle passed in is locked and the socket it is bound too is returned. If an error occurs the err pointer is overwritten with a negative errno code and NULL is returned. The function checks for both invalid handles and passing a handle which is not a socket.
On a success the socket object pointer is returned.
kernel_recvmsg — Receive a message from a socket (kernel space)
int kernel_recvmsg ( | sock, | |
| msg, | ||
| vec, | ||
| num, | ||
| size, | ||
flags); |
struct socket * sock;struct msghdr * msg;struct kvec * vec;size_t num;size_t size;int flags;sock_register — add a socket protocol handler
int sock_register ( | ops); |
const struct net_proto_family * ops;sock_unregister — remove a protocol handler
void sock_unregister ( | family); |
int family;This function is called by a protocol handler that wants to remove its address family, and have it unlinked from the new socket creation.
If protocol handler is a module, then it can use module reference counts to protect against new references. If protocol handler is not a module then it needs to provide its own protection in the ops->create routine.
__alloc_skb — allocate a network buffer
struct sk_buff * __alloc_skb ( | size, | |
| gfp_mask, | ||
| fclone, | ||
node); |
unsigned int size;gfp_t gfp_mask;int fclone;int node;__netdev_alloc_skb — allocate an skbuff for rx on a specific device
struct sk_buff * __netdev_alloc_skb ( | dev, | |
| length, | ||
gfp_mask); |
struct net_device * dev;unsigned int length;gfp_t gfp_mask;devnetwork device to receive on
lengthlength to allocate
gfp_maskget_free_pages mask, passed to alloc_skb
Allocate a new sk_buff and assign it a usage count of one. The buffer has unspecified headroom built in. Users should allocate the headroom they think they need without accounting for the built in space. The built in space is used for optimisations.
NULL is returned if there is no free memory.
dev_alloc_skb — allocate an skbuff for receiving
struct sk_buff * dev_alloc_skb ( | length); |
unsigned int length;Allocate a new sk_buff and assign it a usage count of one. The buffer has unspecified headroom built in. Users should allocate the headroom they think they need without accounting for the built in space. The built in space is used for optimisations.
NULL is returned if there is no free memory. Although this function
allocates memory it can be called from an interrupt.
skb_recycle_check — check if skb can be reused for receive
bool skb_recycle_check ( | skb, | |
skb_size); |
struct sk_buff * skb;int skb_size;
Checks that the skb passed in is not shared or cloned, and
that it is linear and its head portion at least as large as
skb_size so that it can be recycled as a receive buffer.
If these conditions are met, this function does any necessary
reference count dropping and cleans up the skbuff as if it
just came from __alloc_skb.
skb_morph — morph one skb into another
struct sk_buff * skb_morph ( | dst, | |
src); |
struct sk_buff * dst;struct sk_buff * src;skb_clone — duplicate an sk_buff
struct sk_buff * skb_clone ( | skb, | |
gfp_mask); |
struct sk_buff * skb;gfp_t gfp_mask;
Duplicate an sk_buff. The new one is not owned by a socket. Both
copies share the same packet data but not structure. The new
buffer has a reference count of 1. If the allocation fails the
function returns NULL otherwise the new buffer is returned.
If this function is called from an interrupt gfp_mask must be
GFP_ATOMIC.
skb_copy — create private copy of an sk_buff
struct sk_buff * skb_copy ( | skb, | |
gfp_mask); |
const struct sk_buff * skb;gfp_t gfp_mask;
Make a copy of both an sk_buff and its data. This is used when the
caller wishes to modify the data and needs a private copy of the
data to alter. Returns NULL on failure or the pointer to the buffer
on success. The returned buffer has a reference count of 1.
As by-product this function converts non-linear sk_buff to linear
one, so that sk_buff becomes completely private and caller is allowed
to modify all the data of returned buffer. This means that this
function is not recommended for use in circumstances when only
header is going to be modified. Use pskb_copy instead.
pskb_copy — create copy of an sk_buff with private head.
struct sk_buff * pskb_copy ( | skb, | |
gfp_mask); |
struct sk_buff * skb;gfp_t gfp_mask;
Make a copy of both an sk_buff and part of its data, located
in header. Fragmented data remain shared. This is used when
the caller wishes to modify only header of sk_buff and needs
private copy of the header to alter. Returns NULL on failure
or the pointer to the buffer on success.
The returned buffer has a reference count of 1.
pskb_expand_head — reallocate header of sk_buff
int pskb_expand_head ( | skb, | |
| nhead, | ||
| ntail, | ||
gfp_mask); |
struct sk_buff * skb;int nhead;int ntail;gfp_t gfp_mask;skbbuffer to reallocate
nheadroom to add at head
ntailroom to add at tail
gfp_maskallocation priority
Expands (or creates identical copy, if nhead and ntail are zero) header of skb. sk_buff itself is not changed. sk_buff MUST have reference count of 1. Returns zero in the case of success or error, if expansion failed. In the last case, sk_buff is not changed.
All the pointers pointing into skb header may change and must be reloaded after call to this function.
skb_copy_expand — copy and expand sk_buff
struct sk_buff * skb_copy_expand ( | skb, | |
| newheadroom, | ||
| newtailroom, | ||
gfp_mask); |
const struct sk_buff * skb;int newheadroom;int newtailroom;gfp_t gfp_mask;skbbuffer to copy
newheadroomnew free bytes at head
newtailroomnew free bytes at tail
gfp_maskallocation priority
Make a copy of both an sk_buff and its data and while doing so allocate additional space.
This is used when the caller wishes to modify the data and needs a
private copy of the data to alter as well as more space for new fields.
Returns NULL on failure or the pointer to the buffer
on success. The returned buffer has a reference count of 1.
You must pass GFP_ATOMIC as the allocation priority if this function
is called from an interrupt.
skb_pad — zero pad the tail of an skb
int skb_pad ( | skb, | |
pad); |
struct sk_buff * skb;int pad;skb_put — add data to a buffer
unsigned char * skb_put ( | skb, | |
len); |
struct sk_buff * skb;unsigned int len;skb_push — add data to the start of a buffer
unsigned char * skb_push ( | skb, | |
len); |
struct sk_buff * skb;unsigned int len;skb_pull — remove data from the start of a buffer
unsigned char * skb_pull ( | skb, | |
len); |
struct sk_buff * skb;unsigned int len;skb_trim — remove end from a buffer
void skb_trim ( | skb, | |
len); |
struct sk_buff * skb;unsigned int len;__pskb_pull_tail — advance tail of skb header
unsigned char * __pskb_pull_tail ( | skb, | |
delta); |
struct sk_buff * skb;int delta;The function makes a sense only on a fragmented sk_buff, it expands header moving its tail forward and copying necessary data from fragmented part.
sk_buff MUST have reference count of 1.
Returns NULL (and sk_buff does not change) if pull failed
or value of new tail of skb in the case of success.
All the pointers pointing into skb header may change and must be reloaded after call to this function.
skb_store_bits — store bits from kernel buffer to skb
int skb_store_bits ( | skb, | |
| offset, | ||
| from, | ||
len); |
struct sk_buff * skb;int offset;const void * from;int len;skb_dequeue — remove from the head of the queue
struct sk_buff * skb_dequeue ( | list); |
struct sk_buff_head * list;skb_dequeue_tail — remove from the tail of the queue
struct sk_buff * skb_dequeue_tail ( | list); |
struct sk_buff_head * list;skb_queue_head — queue a buffer at the list head
void skb_queue_head ( | list, | |
newsk); |
struct sk_buff_head * list;struct sk_buff * newsk;skb_queue_tail — queue a buffer at the list tail
void skb_queue_tail ( | list, | |
newsk); |
struct sk_buff_head * list;struct sk_buff * newsk;skb_unlink — remove a buffer from a list
void skb_unlink ( | skb, | |
list); |
struct sk_buff * skb;struct sk_buff_head * list;skb_append — append a buffer
void skb_append ( | old, | |
| newsk, | ||
list); |
struct sk_buff * old;struct sk_buff * newsk;struct sk_buff_head * list;skb_insert — insert a buffer
void skb_insert ( | old, | |
| newsk, | ||
list); |
struct sk_buff * old;struct sk_buff * newsk;struct sk_buff_head * list;skb_split — Split fragmented skb to two parts at length len.
void skb_split ( | skb, | |
| skb1, | ||
len); |
struct sk_buff * skb;struct sk_buff * skb1;const u32 len;skb_prepare_seq_read — Prepare a sequential read of skb data
void skb_prepare_seq_read ( | skb, | |
| from, | ||
| to, | ||
st); |
struct sk_buff * skb;unsigned int from;unsigned int to;struct skb_seq_state * st;skb_seq_read — Sequentially read skb data
unsigned int skb_seq_read ( | consumed, | |
| data, | ||
st); |
unsigned int consumed;const u8 ** data;struct skb_seq_state * st;consumednumber of bytes consumed by the caller so far
datadestination pointer for data to be returned
ststate variable
Reads a block of skb data at consumed relative to the
lower offset specified to skb_prepare_seq_read. Assigns
the head of the data block to data and returns the length
of the block or 0 if the end of the skb data or the upper
offset has been reached.
The caller is not required to consume all of the data
returned, i.e. consumed is typically set to the number
of bytes already consumed and the next call to
skb_seq_read will return the remaining part of the block.
skb_abort_seq_read — Abort a sequential read of skb data
void skb_abort_seq_read ( | st); |
struct skb_seq_state * st;skb_find_text — Find a text pattern in skb data
unsigned int skb_find_text ( | skb, | |
| from, | ||
| to, | ||
| config, | ||
state); |
struct sk_buff * skb;unsigned int from;unsigned int to;struct ts_config * config;struct ts_state * state;skb_append_datato_frags — append the user data to a skb
int skb_append_datato_frags ( | sk, | |
| skb, | ||
| getfrag, | ||
| from, | ||
length); |
struct sock * sk;struct sk_buff * skb;int (*getfrag)
(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb);void * from;int length;skb_pull_rcsum — pull skb and update receive checksum
unsigned char * skb_pull_rcsum ( | skb, | |
len); |
struct sk_buff * skb;unsigned int len;skb_segment — Perform protocol segmentation on skb.
struct sk_buff * skb_segment ( | skb, | |
features); |
struct sk_buff * skb;u32 features;skb_cow_data — Check that a socket buffer's data buffers are writable
int skb_cow_data ( | skb, | |
| tailbits, | ||
trailer); |
struct sk_buff * skb;int tailbits;struct sk_buff ** trailer;skbThe socket buffer to check.
tailbitsAmount of trailing space to be added
trailer
Returned pointer to the skb where the tailbits space begins
Make sure that the data buffers attached to a socket buffer are writable. If they are not, private copies are made of the data buffers and the socket buffer is set to use these instead.
If tailbits is given, make sure that there is space to write tailbits
bytes of data beyond current end of socket buffer. trailer will be
set to point to the skb in which this space begins.
The number of scatterlist elements required to completely map the COW'd and extended socket buffer will be returned.
skb_partial_csum_set — set up and verify partial csum values for packet
bool skb_partial_csum_set ( | skb, | |
| start, | ||
off); |
struct sk_buff * skb;u16 start;u16 off;sk_alloc — All socket objects are allocated here
struct sock * sk_alloc ( | net, | |
| family, | ||
| priority, | ||
prot); |
struct net * net;int family;gfp_t priority;struct proto * prot;sk_wait_data — wait for data to arrive at sk_receive_queue
int sk_wait_data ( | sk, | |
timeo); |
struct sock * sk;long * timeo;__sk_mem_schedule — increase sk_forward_alloc and memory_allocated
int __sk_mem_schedule ( | sk, | |
| size, | ||
kind); |
struct sock * sk;int size;int kind;__sk_mem_reclaim — reclaim memory_allocated
void __sk_mem_reclaim ( | sk); |
struct sock * sk;__skb_recv_datagram — Receive a datagram skbuff
struct sk_buff * __skb_recv_datagram ( | sk, | |
| flags, | ||
| peeked, | ||
err); |
struct sock * sk;unsigned flags;int * peeked;int * err;sksocket
flagsMSG_ flags
peekedreturns non-zero if this packet has been seen before
errerror code returned
Get a datagram skbuff, understands the peeking, nonblocking wakeups and possible races. This replaces identical code in packet, raw and udp, as well as the IPX AX.25 and Appletalk. It also finally fixes the long standing peek and read race for datagram sockets. If you alter this routine remember it must be re-entrant.
This function will lock the socket if a skb is returned, so the caller needs to unlock the socket in that case (usually by calling skb_free_datagram)
* It does not lock socket since today. This function is
* free of race conditions. This measure should/can improve
* significantly datagram socket latencies at high loads,
* when data copying to user space takes lots of time.
* (BTW I've just killed the last cli in IP/IPv6/core/netlink/packet
* 8) Great win.)
* --ANK (980729)
The order of the tests when we find no data waiting are specified quite explicitly by POSIX 1003.1g, don't change them without having the standard around please.
skb_kill_datagram — Free a datagram skbuff forcibly
int skb_kill_datagram ( | sk, | |
| skb, | ||
flags); |
struct sock * sk;struct sk_buff * skb;unsigned int flags;This function frees a datagram skbuff that was received by skb_recv_datagram. The flags argument must match the one used for skb_recv_datagram.
If the MSG_PEEK flag is set, and the packet is still on the receive queue of the socket, it will be taken off the queue before it is freed.
This function currently only disables BH when acquiring the sk_receive_queue lock. Therefore it must not be used in a context where that lock is acquired in an IRQ context.
It returns 0 if the packet was removed by us.
skb_copy_datagram_iovec — Copy a datagram to an iovec.
int skb_copy_datagram_iovec ( | skb, | |
| offset, | ||
| to, | ||
len); |
const struct sk_buff * skb;int offset;struct iovec * to;int len;skb_copy_datagram_const_iovec — Copy a datagram to an iovec.
int skb_copy_datagram_const_iovec ( | skb, | |
| offset, | ||
| to, | ||
| to_offset, | ||
len); |
const struct sk_buff * skb;int offset;const struct iovec * to;int to_offset;int len;skb_copy_datagram_from_iovec — Copy a datagram from an iovec.
int skb_copy_datagram_from_iovec ( | skb, | |
| offset, | ||
| from, | ||
| from_offset, | ||
len); |
struct sk_buff * skb;int offset;const struct iovec * from;int from_offset;int len;skb_copy_and_csum_datagram_iovec — Copy and checkum skb to user iovec.
int skb_copy_and_csum_datagram_iovec ( | skb, | |
| hlen, | ||
iov); |
struct sk_buff * skb;int hlen;struct iovec * iov;datagram_poll — generic datagram poll
unsigned int datagram_poll ( | file, | |
| sock, | ||
wait); |
struct file * file;struct socket * sock;poll_table * wait;sk_stream_write_space — stream socket write_space callback.
void sk_stream_write_space ( | sk); |
struct sock * sk;sk_filter — run a packet through a socket filter
int sk_filter ( | sk, | |
skb); |
struct sock * sk;struct sk_buff * skb;Run the filter code and then cut skb->data to correct size returned by sk_run_filter. If pkt_len is 0 we toss packet. If skb->len is smaller than pkt_len we keep whole skb->data. This is the socket level wrapper to sk_run_filter. It returns 0 if the packet should be accepted or -EPERM if the packet should be tossed.
sk_run_filter — run a filter on a socket
unsigned int sk_run_filter ( | skb, | |
fentry); |
const struct sk_buff * skb;const struct sock_filter * fentry;
Decode and apply filter instructions to the skb->data.
Return length to keep, 0 for none. skb is the data we are
filtering, filter is the array of filter instructions.
Because all jumps are guaranteed to be before last instruction,
and last instruction guaranteed to be a RET, we dont need to check
flen. (We used to pass to this function the length of filter)
sk_chk_filter — verify socket filter code
int sk_chk_filter ( | filter, | |
flen); |
struct sock_filter * filter;int flen;Check the user's filter code. If we let some ugly filter code slip through kaboom! The filter must contain no references or jumps that are out of range, no illegal instructions, and must end with a RET instruction.
All jumps are forward as they are not signed.
Returns 0 if the rule set is legal or -EINVAL if not.
sk_filter_release_rcu — Release a socket filter by rcu_head
void sk_filter_release_rcu ( | rcu); |
struct rcu_head * rcu;struct gnet_stats_basic — byte/packet throughput statistics
struct gnet_stats_basic {
__u64 bytes;
__u32 packets;
}; struct gnet_stats_rate_est — rate estimator
struct gnet_stats_rate_est {
__u32 bps;
__u32 pps;
}; struct gnet_stats_queue — queuing statistics
struct gnet_stats_queue {
__u32 qlen;
__u32 backlog;
__u32 drops;
__u32 requeues;
__u32 overlimits;
}; struct gnet_estimator — rate estimator configuration
struct gnet_estimator {
signed char interval;
unsigned char ewma_log;
}; gnet_stats_start_copy_compat — start dumping procedure in compatibility mode
int gnet_stats_start_copy_compat ( | skb, | |
| type, | ||
| tc_stats_type, | ||
| xstats_type, | ||
| lock, | ||
d); |
struct sk_buff * skb;int type;int tc_stats_type;int xstats_type;spinlock_t * lock;struct gnet_dump * d;skbsocket buffer to put statistics TLVs into
typeTLV type for top level statistic TLV
tc_stats_typeTLV type for backward compatibility struct tc_stats TLV
xstats_typeTLV type for backward compatibility xstats TLV
lockstatistics lock
ddumping handle
Initializes the dumping handle, grabs the statistic lock and appends an empty TLV header to the socket buffer for use a container for all other statistic TLVS.
The dumping handle is marked to be in backward compatibility mode telling
all gnet_stats_copy_XXX functions to fill a local copy of struct tc_stats.
Returns 0 on success or -1 if the room in the socket buffer was not sufficient.
gnet_stats_start_copy — start dumping procedure in compatibility mode
int gnet_stats_start_copy ( | skb, | |
| type, | ||
| lock, | ||
d); |
struct sk_buff * skb;int type;spinlock_t * lock;struct gnet_dump * d;gnet_stats_copy_basic — copy basic statistics into statistic TLV
int gnet_stats_copy_basic ( | d, | |
b); |
struct gnet_dump * d;struct gnet_stats_basic_packed * b;gnet_stats_copy_rate_est — copy rate estimator statistics into statistics TLV
int gnet_stats_copy_rate_est ( | d, | |
| b, | ||
r); |
struct gnet_dump * d;const struct gnet_stats_basic_packed * b;struct gnet_stats_rate_est * r;gnet_stats_copy_queue — copy queue statistics into statistics TLV
int gnet_stats_copy_queue ( | d, | |
q); |
struct gnet_dump * d;struct gnet_stats_queue * q;gnet_stats_copy_app — copy application specific statistics into statistics TLV
int gnet_stats_copy_app ( | d, | |
| st, | ||
len); |
struct gnet_dump * d;void * st;int len;
Appends the application sepecific statistics to the top level TLV created by
gnet_stats_start_copy and remembers the data for XSTATS if the dumping
handle is in backward compatibility mode.
Returns 0 on success or -1 with the statistic lock released if the room in the socket buffer was not sufficient.
gnet_stats_finish_copy — finish dumping procedure
int gnet_stats_finish_copy ( | d); |
struct gnet_dump * d;
Corrects the length of the top level TLV to include all TLVs added
by gnet_stats_copy_XXX calls. Adds the backward compatibility TLVs
if gnet_stats_start_copy_compat was used and releases the statistics
lock.
Returns 0 on success or -1 with the statistic lock released if the room in the socket buffer was not sufficient.
gen_new_estimator — create a new rate estimator
int gen_new_estimator ( | bstats, | |
| rate_est, | ||
| stats_lock, | ||
opt); |
struct gnet_stats_basic_packed * bstats;struct gnet_stats_rate_est * rate_est;spinlock_t * stats_lock;struct nlattr * opt;bstatsbasic statistics
rate_estrate estimator statistics
stats_lockstatistics lock
optrate estimator configuration TLV
Creates a new rate estimator with bstats as source and rate_est as destination. A new timer with the interval specified in the configuration TLV is created. Upon each interval, the latest statistics will be read from bstats and the estimated rate will be stored in rate_est with the statistics lock grabed during this period.
Returns 0 on success or a negative error code.
gen_kill_estimator — remove a rate estimator
void gen_kill_estimator ( | bstats, | |
rate_est); |
struct gnet_stats_basic_packed * bstats;struct gnet_stats_rate_est * rate_est;gen_replace_estimator — replace rate estimator configuration
int gen_replace_estimator ( | bstats, | |
| rate_est, | ||
| stats_lock, | ||
opt); |
struct gnet_stats_basic_packed * bstats;struct gnet_stats_rate_est * rate_est;spinlock_t * stats_lock;struct nlattr * opt;xdr_encode_opaque_fixed — Encode fixed length opaque data
__be32 * xdr_encode_opaque_fixed ( | p, | |
| ptr, | ||
nbytes); |
__be32 * p;const void * ptr;unsigned int nbytes;ppointer to current position in XDR buffer.
ptrpointer to data to encode (or NULL)
nbytessize of data.
xdr_encode_opaque — Encode variable length opaque data
__be32 * xdr_encode_opaque ( | p, | |
| ptr, | ||
nbytes); |
__be32 * p;const void * ptr;unsigned int nbytes;xdr_terminate_string — '\0'-terminate a string residing in an xdr_buf
void xdr_terminate_string ( | buf, | |
len); |
struct xdr_buf * buf;const u32 len;xdr_init_encode — Initialize a struct xdr_stream for sending data.
void xdr_init_encode ( | xdr, | |
| buf, | ||
p); |
struct xdr_stream * xdr;struct xdr_buf * buf;__be32 * p;xdrpointer to xdr_stream struct
bufpointer to XDR buffer in which to encode data
pcurrent pointer inside XDR buffer
at the moment the RPC client only passes the length of our
scratch buffer in the xdr_buf's header kvec. Previously this
meant we needed to call xdr_adjust_iovec after encoding the
data. With the new scheme, the xdr_stream manages the details
of the buffer length, and takes care of adjusting the kvec
length for us.
xdr_reserve_space — Reserve buffer space for sending
__be32 * xdr_reserve_space ( | xdr, | |
nbytes); |
struct xdr_stream * xdr;size_t nbytes;xdr_write_pages — Insert a list of pages into an XDR buffer for sending
void xdr_write_pages ( | xdr, | |
| pages, | ||
| base, | ||
len); |
struct xdr_stream * xdr;struct page ** pages;unsigned int base;unsigned int len;xdr_init_decode — Initialize an xdr_stream for decoding data.
void xdr_init_decode ( | xdr, | |
| buf, | ||
p); |
struct xdr_stream * xdr;struct xdr_buf * buf;__be32 * p;xdr_init_decode_pages — Initialize an xdr_stream for decoding data.
void xdr_init_decode_pages ( | xdr, | |
| buf, | ||
| pages, | ||
len); |
struct xdr_stream * xdr;struct xdr_buf * buf;struct page ** pages;unsigned int len;xdr_set_scratch_buffer — Attach a scratch buffer for decoding data.
void xdr_set_scratch_buffer ( | xdr, | |
| buf, | ||
buflen); |
struct xdr_stream * xdr;void * buf;size_t buflen;xdr_inline_decode — Retrieve XDR data to decode
__be32 * xdr_inline_decode ( | xdr, | |
nbytes); |
struct xdr_stream * xdr;size_t nbytes;xdr_read_pages — Ensure page-based XDR data to decode is aligned at current pointer position
void xdr_read_pages ( | xdr, | |
len); |
struct xdr_stream * xdr;unsigned int len;xdr_enter_page — decode data from the XDR page
void xdr_enter_page ( | xdr, | |
len); |
struct xdr_stream * xdr;unsigned int len;svc_print_addr — Format rq_addr field for printing
char * svc_print_addr ( | rqstp, | |
| buf, | ||
len); |
struct svc_rqst * rqstp;char * buf;size_t len;svc_reserve — change the space reserved for the reply to a request.
void svc_reserve ( | rqstp, | |
space); |
struct svc_rqst * rqstp;int space;svc_find_xprt — find an RPC transport instance
struct svc_xprt * svc_find_xprt ( | serv, | |
| xcl_name, | ||
| af, | ||
port); |
struct svc_serv * serv;const char * xcl_name;const sa_family_t af;const unsigned short port;servpointer to svc_serv to search
xcl_nameC string containing transport's class name
afAddress family of transport's local address
porttransport's IP port number
Return the transport instance pointer for the endpoint accepting connections/peer traffic from the specified transport class, address family and port.
Specifying 0 for the address family or port is effectively a wild-card, and will result in matching the first transport in the service's list that has a matching class name.
svc_xprt_names — format a buffer with a list of transport names
int svc_xprt_names ( | serv, | |
| buf, | ||
buflen); |
struct svc_serv * serv;char * buf;const int buflen;xprt_register_transport — register a transport implementation
int xprt_register_transport ( | transport); |
struct xprt_class * transport;xprt_unregister_transport — unregister a transport implementation
int xprt_unregister_transport ( | transport); |
struct xprt_class * transport;xprt_load_transport — load a transport implementation
int xprt_load_transport ( | transport_name); |
const char * transport_name;xprt_reserve_xprt — serialize write access to transports
int xprt_reserve_xprt ( | task); |
struct rpc_task * task;xprt_release_xprt — allow other requests to use a transport
void xprt_release_xprt ( | xprt, | |
task); |
struct rpc_xprt * xprt;struct rpc_task * task;xprt_release_xprt_cong — allow other requests to use a transport
void xprt_release_xprt_cong ( | xprt, | |
task); |
struct rpc_xprt * xprt;struct rpc_task * task;xprt_release_rqst_cong — housekeeping when request is complete
void xprt_release_rqst_cong ( | task); |
struct rpc_task * task;xprt_adjust_cwnd — adjust transport congestion window
void xprt_adjust_cwnd ( | task, | |
result); |
struct rpc_task * task;int result;xprt_wake_pending_tasks — wake all tasks on a transport's pending queue
void xprt_wake_pending_tasks ( | xprt, | |
status); |
struct rpc_xprt * xprt;int status;xprt_wait_for_buffer_space — wait for transport output buffer to clear
void xprt_wait_for_buffer_space ( | task, | |
action); |
struct rpc_task * task;rpc_action action;xprt_write_space — wake the task waiting for transport output buffer space
void xprt_write_space ( | xprt); |
struct rpc_xprt * xprt;xprt_set_retrans_timeout_def — set a request's retransmit timeout
void xprt_set_retrans_timeout_def ( | task); |
struct rpc_task * task;xprt_disconnect_done — mark a transport as disconnected
void xprt_disconnect_done ( | xprt); |
struct rpc_xprt * xprt;xprt_lookup_rqst — find an RPC request corresponding to an XID
struct rpc_rqst * xprt_lookup_rqst ( | xprt, | |
xid); |
struct rpc_xprt * xprt;__be32 xid;xprt_complete_rqst — called when reply processing is complete
void xprt_complete_rqst ( | task, | |
copied); |
struct rpc_task * task;int copied;rpc_wake_up — wake up all rpc_tasks
void rpc_wake_up ( | queue); |
struct rpc_wait_queue * queue;rpc_wake_up_status — wake up all rpc_tasks and set their status value.
void rpc_wake_up_status ( | queue, | |
status); |
struct rpc_wait_queue * queue;int status;rpc_malloc — allocate an RPC buffer
void * rpc_malloc ( | task, | |
size); |
struct rpc_task * task;size_t size;To prevent rpciod from hanging, this allocator never sleeps, returning NULL if the request cannot be serviced immediately. The caller can arrange to sleep in a way that is safe for rpciod.
Most requests are 'small' (under 2KiB) and can be serviced from a mempool, ensuring that NFS reads and writes can always proceed, and that there is good locality of reference for these buffers.
In order to avoid memory starvation triggering more writebacks of NFS requests, we avoid using GFP_KERNEL.
xdr_skb_read_bits — copy some data bits from skb to internal buffer
size_t xdr_skb_read_bits ( | desc, | |
| to, | ||
len); |
struct xdr_skb_reader * desc;void * to;size_t len;xdr_partial_copy_from_skb — copy data out of an skb
ssize_t xdr_partial_copy_from_skb ( | xdr, | |
| base, | ||
| desc, | ||
copy_actor); |
struct xdr_buf * xdr;unsigned int base;struct xdr_skb_reader * desc;xdr_skb_read_actor copy_actor;csum_partial_copy_to_xdr — checksum and copy data
int csum_partial_copy_to_xdr ( | xdr, | |
skb); |
struct xdr_buf * xdr;struct sk_buff * skb;rpc_alloc_iostats — allocate an rpc_iostats structure
struct rpc_iostats * rpc_alloc_iostats ( | clnt); |
struct rpc_clnt * clnt;rpc_free_iostats — release an rpc_iostats structure
void rpc_free_iostats ( | stats); |
struct rpc_iostats * stats;rpc_queue_upcall — queue an upcall message to userspace
int rpc_queue_upcall ( | inode, | |
msg); |
struct inode * inode;struct rpc_pipe_msg * msg;rpc_mkpipe — make an rpc_pipefs file for kernel<->userspace communication
struct dentry * rpc_mkpipe ( | parent, | |
| name, | ||
| private, | ||
| ops, | ||
flags); |
struct dentry * parent;const char * name;void * private;const struct rpc_pipe_ops * ops;int flags;parentdentry of directory to create new “pipe” in
namename of pipe
privateprivate data to associate with the pipe, for the caller's use
opsoperations defining the behavior of the pipe: upcall, downcall, release_pipe, open_pipe, and destroy_msg.
flagsrpc_inode flags
Data is made available for userspace to read by calls to
rpc_queue_upcall. The actual reads will result in calls to
ops->upcall, which will be called with the file pointer,
message, and userspace buffer to copy to.
Writes can come at any time, and do not necessarily have to be
responses to upcalls. They will result in calls to msg->downcall.
The private argument passed here will be available to all these methods
from the file pointer, via RPC_I(file->f_dentry->d_inode)->private.
rpcb_getport_async — obtain the port for a given RPC service on a given host
void rpcb_getport_async ( | task); |
struct rpc_task * task;rpc_bind_new_program — bind a new RPC program to an existing client
struct rpc_clnt * rpc_bind_new_program ( | old, | |
| program, | ||
vers); |
struct rpc_clnt * old;struct rpc_program * program;u32 vers;rpc_run_task — Allocate a new RPC task, then run rpc_execute against it
struct rpc_task * rpc_run_task ( | task_setup_data); |
const struct rpc_task_setup * task_setup_data;rpc_call_sync — Perform a synchronous RPC call
int rpc_call_sync ( | clnt, | |
| msg, | ||
flags); |
struct rpc_clnt * clnt;const struct rpc_message * msg;int flags;rpc_call_async — Perform an asynchronous RPC call
int rpc_call_async ( | clnt, | |
| msg, | ||
| flags, | ||
| tk_ops, | ||
data); |
struct rpc_clnt * clnt;const struct rpc_message * msg;int flags;const struct rpc_call_ops * tk_ops;void * data;rpc_peeraddr — extract remote peer address from clnt's xprt
size_t rpc_peeraddr ( | clnt, | |
| buf, | ||
bufsize); |
struct rpc_clnt * clnt;struct sockaddr * buf;size_t bufsize;wimax_msg_alloc — Create a new skb for sending a message to userspace
struct sk_buff * wimax_msg_alloc ( | wimax_dev, | |
| pipe_name, | ||
| msg, | ||
| size, | ||
gfp_flags); |
struct wimax_dev * wimax_dev;const char * pipe_name;const void * msg;size_t size;gfp_t gfp_flags;wimax_devWiMAX device descriptor
pipe_name"named pipe" the message will be sent to
msgpointer to the message data to send
sizesize of the message to send (in bytes), including the header.
gfp_flagsflags for memory allocation.
Allocates an skb that will contain the message to send to user space over the messaging pipe and initializes it, copying the payload.
Once this call is done, you can deliver it with
wimax_msg_send.
Don't use skb_push/skb_pull/skb_reserve on the skb, as
wimax_msg_send depends on skb->data being placed at the
beginning of the user message.
Unlike other WiMAX stack calls, this call can be used way early,
even before wimax_dev_add is called, as long as the
wimax_dev->net_dev pointer is set to point to a proper
net_dev. This is so that drivers can use it early in case they need
to send stuff around or communicate with user space.
wimax_msg_data_len — Return a pointer and size of a message's payload
const void * wimax_msg_data_len ( | msg, | |
size); |
struct sk_buff * msg;size_t * size;wimax_msg_data — Return a pointer to a message's payload
const void * wimax_msg_data ( | msg); |
struct sk_buff * msg;wimax_msg_len — Return a message's payload length
ssize_t wimax_msg_len ( | msg); |
struct sk_buff * msg;wimax_msg_send — Send a pre-allocated message to user space
int wimax_msg_send ( | wimax_dev, | |
skb); |
struct wimax_dev * wimax_dev;struct sk_buff * skb;wimax_devWiMAX device descriptor
skb
struct sk_buff returned by wimax_msg_alloc. Note the
ownership of skb is transferred to this function.
Sends a free-form message that was preallocated with
wimax_msg_alloc and filled up.
Assumes that once you pass an skb to this function for sending, it owns it and will release it when done (on success).
Don't use skb_push/skb_pull/skb_reserve on the skb, as
wimax_msg_send depends on skb->data being placed at the
beginning of the user message.
Unlike other WiMAX stack calls, this call can be used way early,
even before wimax_dev_add is called, as long as the
wimax_dev->net_dev pointer is set to point to a proper
net_dev. This is so that drivers can use it early in case they need
to send stuff around or communicate with user space.
wimax_msg — Send a message to user space
int wimax_msg ( | wimax_dev, | |
| pipe_name, | ||
| buf, | ||
| size, | ||
gfp_flags); |
struct wimax_dev * wimax_dev;const char * pipe_name;const void * buf;size_t size;gfp_t gfp_flags;wimax_reset — Reset a WiMAX device
int wimax_reset ( | wimax_dev); |
struct wimax_dev * wimax_dev;
0 if ok and a warm reset was done (the device still exists in
the system).
-ENODEV if a cold/bus reset had to be done (device has
disconnected and reconnected, so current handle is not valid
any more).
-EINVAL if the device is not even registered.
Any other negative error code shall be considered as non-recoverable.
wimax_report_rfkill_hw — Reports changes in the hardware RF switch
void wimax_report_rfkill_hw ( | wimax_dev, | |
state); |
struct wimax_dev * wimax_dev;enum wimax_rf_state state;wimax_devWiMAX device descriptor
state
New state of the RF Kill switch. WIMAX_RF_ON radio on,
WIMAX_RF_OFF radio off.
When the device detects a change in the state of thehardware RF switch, it must call this function to let the WiMAX kernel stack know that the state has changed so it can be properly propagated.
The WiMAX stack caches the state (the driver doesn't need to). As well, as the change is propagated it will come back as a request to change the software state to mirror the hardware state.
If the device doesn't have a hardware kill switch, just report
it on initialization as always on (WIMAX_RF_ON, radio on).
wimax_report_rfkill_sw — Reports changes in the software RF switch
void wimax_report_rfkill_sw ( | wimax_dev, | |
state); |
struct wimax_dev * wimax_dev;enum wimax_rf_state state;wimax_devWiMAX device descriptor
state
New state of the RF kill switch. WIMAX_RF_ON radio on,
WIMAX_RF_OFF radio off.
Reports changes in the software RF switch state to the the WiMAX stack.
The main use is during initialization, so the driver can query the device for its current software radio kill switch state and feed it to the system.
On the side, the device does not change the software state by itself. In practice, this can happen, as the device might decide to switch (in software) the radio off for different reasons.
wimax_rfkill — Set the software RF switch state for a WiMAX device
int wimax_rfkill ( | wimax_dev, | |
state); |
struct wimax_dev * wimax_dev;enum wimax_rf_state state;
>= 0 toggle state if ok, < 0 errno code on error. The toggle state is returned as a bitmap, bit 0 being the hardware RF state, bit 1 the software RF state.
0 means disabled (WIMAX_RF_ON, radio on), 1 means enabled radio
off (WIMAX_RF_OFF).
wimax_state_change — Set the current state of a WiMAX device
void wimax_state_change ( | wimax_dev, | |
new_state); |
struct wimax_dev * wimax_dev;enum wimax_st new_state;This implements the state changes for the wimax devices. It will
- verify that the state transition is legal (for now it'll just print a warning if not) according to the table in linux/wimax.h's documentation for 'enum wimax_st'.
- perform the actions needed for leaving the current state and whichever are needed for entering the new state.
- issue a report to user space indicating the new state (and an optional payload with information about the new state).
wimax_state_get — Return the current state of a WiMAX device
enum wimax_st wimax_state_get ( | wimax_dev); |
struct wimax_dev * wimax_dev;wimax_dev_init — initialize a newly allocated instance
void wimax_dev_init ( | wimax_dev); |
struct wimax_dev * wimax_dev;wimax_dev_add — Register a new WiMAX device
int wimax_dev_add ( | wimax_dev, | |
net_dev); |
struct wimax_dev * wimax_dev;struct net_device * net_dev;wimax_dev
WiMAX device descriptor (as embedded in your net_dev's
priv data). You must have called wimax_dev_init on it before.
net_dev
net device the wimax_dev is associated with. The
function expects SET_NETDEV_DEV and register_netdev were
already called on it.
Registers the new WiMAX device, sets up the user-kernel control interface (generic netlink) and common WiMAX infrastructure.
Note that the parts that will allow interaction with user space are setup at the very end, when the rest is in place, as once that happens, the driver might get user space control requests via netlink or from debugfs that might translate into calls into wimax_dev->op_*().
wimax_dev_rm — Unregister an existing WiMAX device
void wimax_dev_rm ( | wimax_dev); |
struct wimax_dev * wimax_dev;
Unregisters a WiMAX device previously registered for use with
wimax_add_rm.
IMPORTANT! Must call before calling unregister_netdev.
After this function returns, you will not get any more user space control requests (via netlink or debugfs) and thus to wimax_dev->ops.
Reentrancy control is ensured by setting the state to
__WIMAX_ST_QUIESCING. rfkill operations coming through
wimax_*rfkill*() will be stopped by the quiescing state; ops coming
from the rfkill subsystem will be stopped by the support being
removed by wimax_rfkill_rm.
struct wimax_dev — Generic WiMAX device
struct wimax_dev {
struct net_device * net_dev;
struct list_head id_table_node;
struct mutex mutex;
struct mutex mutex_reset;
enum wimax_st state;
int (* op_msg_from_user) (struct wimax_dev *wimax_dev,const char *,const void *, size_t,const struct genl_info *info);
int (* op_rfkill_sw_toggle) (struct wimax_dev *wimax_dev,enum wimax_rf_state);
int (* op_reset) (struct wimax_dev *wimax_dev);
struct rfkill * rfkill;
unsigned rf_hw;
unsigned rf_sw;
char name[32];
struct dentry * debugfs_dentry;
}; [fill] Pointer to the struct net_device this WiMAX device implements.
[private] link to the list of wimax devices kept by id-table.c. Protected by it's own spinlock.
[private] Serializes all concurrent access and execution of operations.
[private] Serializes reset operations. Needs to be a different mutex because as part of the reset operation, the driver has to call back into the stack to do things such as state change, that require wimax_dev->mutex.
[private] Current state of the WiMAX device.
[fill] Driver-specific operation to
handle a raw message from user space to the driver. The
driver can send messages to user space using with
wimax_msg_to_user.
[fill] Driver-specific operation to act on userspace (or any other agent) requesting the WiMAX device to change the RF Kill software switch (WIMAX_RF_ON or WIMAX_RF_OFF). If such hardware support is not present, it is assumed the radio cannot be switched off and it is always on (and the stack will error out when trying to switch it off). In such case, this function pointer can be left as NULL.
[fill] Driver specific operation to reset the device. This operation should always attempt first a warm reset that does not disconnect the device from the bus and return 0. If that fails, it should resort to some sort of cold or bus reset (even if it implies a bus disconnection and device disappearance). In that case, -ENODEV should be returned to indicate the device is gone. This operation has to be synchronous, and return only when the reset is complete. In case of having had to resort to bus/cold reset implying a device disconnection, the call is allowed to return inmediately.
[private] integration into the RF-Kill infrastructure.
[private] State of the hardware radio switch (OFF/ON)
[private] State of the software radio switch (OFF/ON)
[fill] A way to identify this device. We need to register a
name with many subsystems (rfkill, workqueue creation, etc).
We can't use the network device name as that
might change and in some instances we don't know it yet (until
we don't call register_netdev). So we generate an unique one
using the driver name and device bus id, place it here and use
it across the board. Recommended naming:
DRIVERNAME-BUSNAME:BUSID (dev->bus->name, dev->bus_id).
[private] Used to hook up a debugfs entry. This shows up in the debugfs root as wimax\:DEVICENAME.
wimax_dev->mutex is NOT locked when this op is being
called; however, wimax_dev->mutex_reset IS locked to ensure
serialization of calls to wimax_reset.
See wimax_reset's documentation.
This structure defines a common interface to access all WiMAX devices from different vendors and provides a common API as well as a free-form device-specific messaging channel.
1. Embed a struct wimax_dev at *the beginning* the network
device structure so that netdev_priv points to it.
2. memset it to zero
3. Initialize with wimax_dev_init. This will leave the WiMAX
device in the __WIMAX_ST_NULL state.
4. Fill all the fields marked with [fill]; once called
wimax_dev_add, those fields CANNOT be modified.
5. Call wimax_dev_add *after* registering the network
device. This will leave the WiMAX device in the WIMAX_ST_DOWN
state.
Protect the driver's net_device->open against succeeding if
the wimax device state is lower than WIMAX_ST_DOWN.
6. Select when the device is going to be turned on/initialized;
for example, it could be initialized on 'ifconfig up' (when the
netdev op 'open' is called on the driver).
When the device is initialized (at `ifconfig up` time, or right
after calling wimax_dev_add from _probe, make sure the
following steps are taken
a. Move the device to WIMAX_ST_UNINITIALIZED. This is needed so
some API calls that shouldn't work until the device is ready
can be blocked.
b. Initialize the device. Make sure to turn the SW radio switch
off and move the device to state WIMAX_ST_RADIO_OFF when
done. When just initialized, a device should be left in RADIO
OFF state until user space devices to turn it on.
c. Query the device for the state of the hardware rfkill switch
and call wimax_rfkill_report_hw and wimax_rfkill_report_sw
as needed. See below.
wimax_dev_rm undoes before unregistering the network device. Once
wimax_dev_add is called, the driver can get called on the
wimax_dev->op_* function pointers
The stack provides a mutex for each device that will disallow API calls happening concurrently; thus, op calls into the driver through the wimax_dev->op*() function pointers will always be serialized and *never* concurrent.
For locking, take wimax_dev->mutex is taken; (most) operations in
the API have to check for wimax_dev_is_ready to return 0 before
continuing (this is done internally).
The WiMAX device is reference counted by the associated network
device. The only operation that can be used to reference the device
is wimax_dev_get_by_genl_info, and the reference it acquires has
to be released with dev_put(wimax_dev->net_dev).
At startup, both HW and SW radio switchess are assumed to be off.
At initialization time [after calling wimax_dev_add], have the
driver query the device for the status of the software and hardware
RF kill switches and call wimax_report_rfkill_hw and
wimax_rfkill_report_sw to indicate their state. If any is
missing, just call it to indicate it is ON (radio always on).
Whenever the driver detects a change in the state of the RF kill
switches, it should call wimax_report_rfkill_hw or
wimax_report_rfkill_sw to report it to the stack.
enum wimax_st — The different states of a WiMAX device
enum wimax_st {
__WIMAX_ST_NULL,
WIMAX_ST_DOWN,
__WIMAX_ST_QUIESCING,
WIMAX_ST_UNINITIALIZED,
WIMAX_ST_RADIO_OFF,
WIMAX_ST_READY,
WIMAX_ST_SCANNING,
WIMAX_ST_CONNECTING,
WIMAX_ST_CONNECTED,
__WIMAX_ST_INVALID
};
The device structure has been allocated and zeroed,
but still wimax_dev_add hasn't been called. There is no state.
The device has been registered with the WiMAX and
networking stacks, but it is not initialized (normally that is
done with 'ifconfig DEV up' [or equivalent], which can upload
firmware and enable communications with the device).
In this state, the device is powered down and using as less
power as possible.
This state is the default after a call to wimax_dev_add. It
is ok to have drivers move directly to WIMAX_ST_UNINITIALIZED
or WIMAX_ST_RADIO_OFF in _probe after the call to
wimax_dev_add.
It is recommended that the driver leaves this state when
calling 'ifconfig DEV up' and enters it back on 'ifconfig DEV
down'.
The device is being torn down, so no API operations are allowed to proceed except the ones needed to complete the device clean up process.
[optional] Communication with the device is setup, but the device still requires some configuration before being operational. Some WiMAX API calls might work.
The device is fully up; radio is off (wether by hardware or software switches). It is recommended to always leave the device in this state after initialization.
The device is fully up and radio is on.
[optional] The device has been instructed to scan. In this state, the device cannot be actively connected to a network.
The device is connecting to a network. This state exists because in some devices, the connect process can include a number of negotiations between user space, kernel space and the device. User space needs to know what the device is doing. If the connect sequence in a device is atomic and fast, the device can transition directly to CONNECTED
The device is connected to a network.
This is an invalid state used to mark the maximum numeric value of states.
Transitions from one state to another one are atomic and can only
be caused in kernel space with wimax_state_change. To read the
state, use wimax_state_get.
States starting with __ are internal and shall not be used or referred to by drivers or userspace. They look ugly, but that's the point -- if any use is made non-internal to the stack, it is easier to catch on review.
All API operations [with well defined exceptions] will take the
device mutex before starting and then check the state. If the state
is __WIMAX_ST_NULL, WIMAX_ST_DOWN, WIMAX_ST_UNINITIALIZED or
__WIMAX_ST_QUIESCING, it will drop the lock and quit with
-EINVAL, -ENOMEDIUM, -ENOTCONN or -ESHUTDOWN.
The order of the definitions is important, so we can do numerical
comparisons (eg: < WIMAX_ST_RADIO_OFF means the device is not ready
to operate).
Table of Contents
dev_add_pack — add packet handler
void dev_add_pack ( | pt); |
struct packet_type * pt;Add a protocol handler to the networking stack. The passed packet_type is linked into kernel lists and may not be freed until it has been removed from the kernel lists.
This call does not sleep therefore it can not guarantee all CPU's that are in middle of receiving packets will see the new packet type (until the next received packet).
__dev_remove_pack — remove packet handler
void __dev_remove_pack ( | pt); |
struct packet_type * pt;
Remove a protocol handler that was previously added to the kernel
protocol handlers by dev_add_pack. The passed packet_type is removed
from the kernel lists and can be freed or reused once this function
returns.
The packet type might still be in use by receivers and must not be freed until after all the CPU's have gone through a quiescent state.
dev_remove_pack — remove packet handler
void dev_remove_pack ( | pt); |
struct packet_type * pt;
Remove a protocol handler that was previously added to the kernel
protocol handlers by dev_add_pack. The passed packet_type is removed
from the kernel lists and can be freed or reused once this function
returns.
This call sleeps to guarantee that no CPU is looking at the packet type after return.
netdev_boot_setup_check — check boot time settings
int netdev_boot_setup_check ( | dev); |
struct net_device * dev;__dev_get_by_name — find a device by its name
struct net_device * __dev_get_by_name ( | net, | |
name); |
struct net * net;const char * name;dev_get_by_name_rcu — find a device by its name
struct net_device * dev_get_by_name_rcu ( | net, | |
name); |
struct net * net;const char * name;dev_get_by_name — find a device by its name
struct net_device * dev_get_by_name ( | net, | |
name); |
struct net * net;const char * name;__dev_get_by_index — find a device by its ifindex
struct net_device * __dev_get_by_index ( | net, | |
ifindex); |
struct net * net;int ifindex;dev_get_by_index_rcu — find a device by its ifindex
struct net_device * dev_get_by_index_rcu ( | net, | |
ifindex); |
struct net * net;int ifindex;dev_get_by_index — find a device by its ifindex
struct net_device * dev_get_by_index ( | net, | |
ifindex); |
struct net * net;int ifindex;dev_getbyhwaddr_rcu — find a device by its hardware address
struct net_device * dev_getbyhwaddr_rcu ( | net, | |
| type, | ||
ha); |
struct net * net;unsigned short type;const char * ha;dev_get_by_flags_rcu — find any device with given flags
struct net_device * dev_get_by_flags_rcu ( | net, | |
| if_flags, | ||
mask); |
struct net * net;unsigned short if_flags;unsigned short mask;dev_valid_name — check if name is okay for network device
int dev_valid_name ( | name); |
const char * name;dev_alloc_name — allocate a name for a device
int dev_alloc_name ( | dev, | |
name); |
struct net_device * dev;const char * name;
Passed a format string - eg “ltd” it will try and find a suitable
id. It scans list of devices to build up a free map, then chooses
the first empty slot. The caller must hold the dev_base or rtnl lock
while allocating the name and adding the device in order to avoid
duplicates.
Limited to bits_per_byte * page size devices (ie 32K on most platforms).
Returns the number of the unit assigned or a negative errno code.
netdev_features_change — device changes features
void netdev_features_change ( | dev); |
struct net_device * dev;netdev_state_change — device changes state
void netdev_state_change ( | dev); |
struct net_device * dev;dev_load — load a network module
void dev_load ( | net, | |
name); |
struct net * net;const char * name;dev_open — prepare an interface for use.
int dev_open ( | dev); |
struct net_device * dev;
Takes a device from down to up state. The device's private open
function is invoked and then the multicast lists are loaded. Finally
the device is moved into the up state and a NETDEV_UP message is
sent to the netdev notifier chain.
Calling this function on an active interface is a nop. On a failure a negative errno code is returned.
dev_disable_lro — disable Large Receive Offload on a device
void dev_disable_lro ( | dev); |
struct net_device * dev;register_netdevice_notifier — register a network notifier block
int register_netdevice_notifier ( | nb); |
struct notifier_block * nb;Register a notifier to be called when network device events occur. The notifier passed is linked into the kernel structures and must not be reused until it has been unregistered. A negative errno code is returned on a failure.
When registered all registration and up events are replayed to the new notifier to allow device to have a race free view of the network device list.
unregister_netdevice_notifier — unregister a network notifier block
int unregister_netdevice_notifier ( | nb); |
struct notifier_block * nb;call_netdevice_notifiers — call all network notifier blocks
int call_netdevice_notifiers ( | val, | |
dev); |
unsigned long val;struct net_device * dev;dev_forward_skb — loopback an skb to another netif
int dev_forward_skb ( | dev, | |
skb); |
struct net_device * dev;struct sk_buff * skb;NET_RX_SUCCESS (no congestion) NET_RX_DROP (packet was dropped, but freed)
dev_forward_skb can be used for injecting an skb from the start_xmit function of one device into the receive queue of another device.
The receiving device may be in another namespace, so we have to clear all information in the skb that could impact namespace isolation.
netif_set_real_num_rx_queues — set actual number of RX queues used
int netif_set_real_num_rx_queues ( | dev, | |
rxq); |
struct net_device * dev;unsigned int rxq;netif_device_detach — mark device as removed
void netif_device_detach ( | dev); |
struct net_device * dev;netif_device_attach — mark device as attached
void netif_device_attach ( | dev); |
struct net_device * dev;skb_set_dev — - assign a new device to a buffer
void skb_set_dev ( | skb, | |
dev); |
struct sk_buff * skb;struct net_device * dev;skb_gso_segment — Perform segmentation on skb.
struct sk_buff * skb_gso_segment ( | skb, | |
features); |
struct sk_buff * skb;u32 features;dev_queue_xmit — transmit a buffer
int dev_queue_xmit ( | skb); |
struct sk_buff * skb;Queue a buffer for transmission to a network device. The caller must have set the device and priority and built the buffer before calling this function. The function can be called from an interrupt.
A negative errno code is returned on a failure. A success does not guarantee the frame will be transmitted as it may be dropped due to congestion or traffic shaping.
----------------------------------------------------------------------------------- I notice this method can also return errors from the queue disciplines, including NET_XMIT_DROP, which is a positive value. So, errors can also be positive.
Regardless of the return value, the skb is consumed, so it is currently difficult to retry a send to this method. (You can bump the ref count before sending to hold a reference for retry if you are careful.)
When calling this method, interrupts MUST be enabled. This is because the BH enable code must have IRQs enabled so that it will not deadlock. --BLG
rps_may_expire_flow — check whether an RFS hardware filter may be removed
bool rps_may_expire_flow ( | dev, | |
| rxq_index, | ||
| flow_id, | ||
filter_id); |
struct net_device * dev;u16 rxq_index;u32 flow_id;u16 filter_id;netif_rx — post buffer to the network code
int netif_rx ( | skb); |
struct sk_buff * skb;netdev_rx_handler_register — register receive handler
int netdev_rx_handler_register ( | dev, | |
| rx_handler, | ||
rx_handler_data); |
struct net_device * dev;rx_handler_func_t * rx_handler;void * rx_handler_data;netdev_rx_handler_unregister — unregister receive handler
void netdev_rx_handler_unregister ( | dev); |
struct net_device * dev;netif_receive_skb — process receive buffer from network
int netif_receive_skb ( | skb); |
struct sk_buff * skb;
netif_receive_skb is the main receive data processing function.
It always succeeds. The buffer may be dropped during processing
for congestion control or by the protocol layers.
This function may only be called from softirq context and interrupts should be enabled.
Return values (usually ignored):
__napi_schedule — schedule for receive
void __napi_schedule ( | n); |
struct napi_struct * n;register_gifconf — register a SIOCGIF handler
int register_gifconf ( | family, | |
gifconf); |
unsigned int family;gifconf_func_t * gifconf;netdev_set_master — set up master pointer
int netdev_set_master ( | slave, | |
master); |
struct net_device * slave;struct net_device * master;netdev_set_bond_master — set up bonding master/slave pair
int netdev_set_bond_master ( | slave, | |
master); |
struct net_device * slave;struct net_device * master;dev_set_promiscuity — update promiscuity count on a device
int dev_set_promiscuity ( | dev, | |
inc); |
struct net_device * dev;int inc;Add or remove promiscuity from a device. While the count in the device remains above zero the interface remains promiscuous. Once it hits zero the device reverts back to normal filtering operation. A negative inc value is used to drop promiscuity on the device. Return 0 if successful or a negative errno code on error.
dev_set_allmulti — update allmulti count on a device
int dev_set_allmulti ( | dev, | |
inc); |
struct net_device * dev;int inc;
Add or remove reception of all multicast frames to a device. While the
count in the device remains above zero the interface remains listening
to all interfaces. Once it hits zero the device reverts back to normal
filtering operation. A negative inc value is used to drop the counter
when releasing a resource needing all multicasts.
Return 0 if successful or a negative errno code on error.
dev_ethtool_get_settings —
call device's ethtool_ops::get_settings
int dev_ethtool_get_settings ( | dev, | |
cmd); |
struct net_device * dev;struct ethtool_cmd * cmd;dev_get_flags — get flags reported to userspace
unsigned dev_get_flags ( | dev); |
const struct net_device * dev;dev_change_flags — change device settings
int dev_change_flags ( | dev, | |
flags); |
struct net_device * dev;unsigned flags;dev_set_mtu — Change maximum transfer unit
int dev_set_mtu ( | dev, | |
new_mtu); |
struct net_device * dev;int new_mtu;dev_set_group — Change group this device belongs to
void dev_set_group ( | dev, | |
new_group); |
struct net_device * dev;int new_group;dev_set_mac_address — Change Media Access Control Address
int dev_set_mac_address ( | dev, | |
sa); |
struct net_device * dev;struct sockaddr * sa;netdev_update_features — recalculate device features
void netdev_update_features ( | dev); |
struct net_device * dev;netdev_change_features — recalculate device features
void netdev_change_features ( | dev); |
struct net_device * dev;netif_stacked_transfer_operstate — transfer operstate
void netif_stacked_transfer_operstate ( | rootdev, | |
dev); |
const struct net_device * rootdev;struct net_device * dev;register_netdevice — register a network device
int register_netdevice ( | dev); |
struct net_device * dev;
Take a completed network device structure and add it to the kernel
interfaces. A NETDEV_REGISTER message is sent to the netdev notifier
chain. 0 is returned on success. A negative errno code is returned
on a failure to set up the device, or if the name is a duplicate.
Callers must hold the rtnl semaphore. You may want
register_netdev instead of this.
init_dummy_netdev — init a dummy network device for NAPI
int init_dummy_netdev ( | dev); |
struct net_device * dev;This takes a network device structure and initialize the minimum amount of fields so it can be used to schedule NAPI polls without registering a full blown interface. This is to be used by drivers that need to tie several hardware interfaces to a single NAPI poll scheduler due to HW limitations.
register_netdev — register a network device
int register_netdev ( | dev); |
struct net_device * dev;
Take a completed network device structure and add it to the kernel
interfaces. A NETDEV_REGISTER message is sent to the netdev notifier
chain. 0 is returned on success. A negative errno code is returned
on a failure to set up the device, or if the name is a duplicate.
This is a wrapper around register_netdevice that takes the rtnl semaphore and expands the device name if you passed a format string to alloc_netdev.
dev_get_stats — get network device statistics
struct rtnl_link_stats64 * dev_get_stats ( | dev, | |
storage); |
struct net_device * dev;struct rtnl_link_stats64 * storage;alloc_netdev_mqs — allocate network device
struct net_device * alloc_netdev_mqs ( | sizeof_priv, | |
| name, | ||
| setup, | ||
| txqs, | ||
rxqs); |
int sizeof_priv;const char * name;void (*setup)
(struct net_device *);unsigned int txqs;unsigned int rxqs;synchronize_net — Synchronize with packet receive processing
void synchronize_net ( | void); |
void;unregister_netdevice_queue — remove device from the kernel
void unregister_netdevice_queue ( | dev, | |
head); |
struct net_device * dev;struct list_head * head;unregister_netdevice_many — unregister many devices
void unregister_netdevice_many ( | head); |
struct list_head * head;unregister_netdev — remove device from the kernel
void unregister_netdev ( | dev); |
struct net_device * dev;dev_change_net_namespace — move device to different nethost namespace
int dev_change_net_namespace ( | dev, | |
| net, | ||
pat); |
struct net_device * dev;struct net * net;const char * pat;netdev_increment_features — increment feature set by one
u32 netdev_increment_features ( | all, | |
| one, | ||
mask); |
u32 all;u32 one;u32 mask;eth_header — create the Ethernet header
int eth_header ( | skb, | |
| dev, | ||
| type, | ||
| daddr, | ||
| saddr, | ||
len); |
struct sk_buff * skb;struct net_device * dev;unsigned short type;const void * daddr;const void * saddr;unsigned len;eth_rebuild_header — rebuild the Ethernet MAC header.
int eth_rebuild_header ( | skb); |
struct sk_buff * skb;eth_type_trans — determine the packet's protocol ID.
__be16 eth_type_trans ( | skb, | |
dev); |
struct sk_buff * skb;struct net_device * dev;eth_header_parse — extract hardware address from packet
int eth_header_parse ( | skb, | |
haddr); |
const struct sk_buff * skb;unsigned char * haddr;eth_header_cache — fill cache entry from neighbour
int eth_header_cache ( | neigh, | |
hh); |
const struct neighbour * neigh;struct hh_cache * hh;eth_header_cache_update — update cache entry
void eth_header_cache_update ( | hh, | |
| dev, | ||
haddr); |
struct hh_cache * hh;const struct net_device * dev;const unsigned char * haddr;eth_mac_addr — set new Ethernet hardware address
int eth_mac_addr ( | dev, | |
p); |
struct net_device * dev;void * p;eth_change_mtu — set new MTU size
int eth_change_mtu ( | dev, | |
new_mtu); |
struct net_device * dev;int new_mtu;ether_setup — setup Ethernet network device
void ether_setup ( | dev); |
struct net_device * dev;alloc_etherdev_mqs — Allocates and sets up an Ethernet device
struct net_device * alloc_etherdev_mqs ( | sizeof_priv, | |
| txqs, | ||
rxqs); |
int sizeof_priv;unsigned int txqs;unsigned int rxqs;netif_carrier_off — clear carrier
void netif_carrier_off ( | dev); |
struct net_device * dev;netif_notify_peers —
notify network peers about existence of dev
void netif_notify_peers ( | dev); |
struct net_device * dev;is_zero_ether_addr — Determine if give Ethernet address is all zeros.
int is_zero_ether_addr ( | addr); |
const u8 * addr;is_multicast_ether_addr — Determine if the Ethernet address is a multicast.
int is_multicast_ether_addr ( | addr); |
const u8 * addr;is_local_ether_addr — Determine if the Ethernet address is locally-assigned one (IEEE 802).
int is_local_ether_addr ( | addr); |
const u8 * addr;is_broadcast_ether_addr — Determine if the Ethernet address is broadcast
int is_broadcast_ether_addr ( | addr); |
const u8 * addr;is_unicast_ether_addr — Determine if the Ethernet address is unicast
int is_unicast_ether_addr ( | addr); |
const u8 * addr;is_valid_ether_addr — Determine if the given Ethernet address is valid
int is_valid_ether_addr ( | addr); |
const u8 * addr;random_ether_addr — Generate software assigned random Ethernet address
void random_ether_addr ( | addr); |
u8 * addr;dev_hw_addr_random — Create random MAC and set device flag
void dev_hw_addr_random ( | dev, | |
hwaddr); |
struct net_device * dev;u8 * hwaddr;compare_ether_addr — Compare two Ethernet addresses
unsigned compare_ether_addr ( | addr1, | |
addr2); |
const u8 * addr1;const u8 * addr2;compare_ether_addr_64bits — Compare two Ethernet addresses
unsigned compare_ether_addr_64bits ( | addr1[6+2], | |
addr2[6+2]); |
const u8 addr1[6+2];const u8 addr2[6+2];Compare two ethernet addresses, returns 0 if equal. Same result than “memcmp(addr1, addr2, ETH_ALEN)” but without conditional branches, and possibly long word memory accesses on CPU allowing cheap unaligned memory reads. arrays = { byte1, byte2, byte3, byte4, byte6, byte7, pad1, pad2}
Please note that alignment of addr1 & addr2 is only guaranted to be 16 bits.
is_etherdev_addr — Tell if given Ethernet address belongs to the device.
bool is_etherdev_addr ( | dev, | |
addr[6 + 2]); |
const struct net_device * dev;const u8 addr[6 + 2];compare_ether_header — Compare two Ethernet headers
unsigned long compare_ether_header ( | a, | |
b); |
const void * a;const void * b;napi_schedule_prep — check if napi can be scheduled
int napi_schedule_prep ( | n); |
struct napi_struct * n;napi_disable — prevent NAPI from scheduling
void napi_disable ( | n); |
struct napi_struct * n;napi_synchronize — wait until NAPI is not running
void napi_synchronize ( | n); |
const struct napi_struct * n;netdev_priv — access network device private data
void * netdev_priv ( | dev); |
const struct net_device * dev;netif_start_queue — allow transmit
void netif_start_queue ( | dev); |
struct net_device * dev;netif_wake_queue — restart transmit
void netif_wake_queue ( | dev); |
struct net_device * dev;netif_stop_queue — stop transmitted packets
void netif_stop_queue ( | dev); |
struct net_device * dev;netif_queue_stopped — test if transmit queue is flowblocked
int netif_queue_stopped ( | dev); |
const struct net_device * dev;netif_start_subqueue — allow sending packets on subqueue
void netif_start_subqueue ( | dev, | |
queue_index); |
struct net_device * dev;u16 queue_index;netif_stop_subqueue — stop sending packets on subqueue
void netif_stop_subqueue ( | dev, | |
queue_index); |
struct net_device * dev;u16 queue_index;__netif_subqueue_stopped — test status of subqueue
int __netif_subqueue_stopped ( | dev, | |
queue_index); |
const struct net_device * dev;u16 queue_index;netif_wake_subqueue — allow sending packets on subqueue
void netif_wake_subqueue ( | dev, | |
queue_index); |
struct net_device * dev;u16 queue_index;netif_is_multiqueue — test if device has multiple transmit queues
int netif_is_multiqueue ( | dev); |
const struct net_device * dev;netif_carrier_ok — test if carrier present
int netif_carrier_ok ( | dev); |
const struct net_device * dev;netif_dormant_on — mark device as dormant.
void netif_dormant_on ( | dev); |
struct net_device * dev;Mark device as dormant (as per RFC2863).
The dormant state indicates that the relevant interface is not actually in a condition to pass packets (i.e., it is not 'up') but is in a “pending” state, waiting for some external event. For “on- demand” interfaces, this new state identifies the situation where the interface is waiting for events to place it in the up state.
netif_dormant_off — set device as not dormant.
void netif_dormant_off ( | dev); |
struct net_device * dev;netif_dormant — test if carrier present
int netif_dormant ( | dev); |
const struct net_device * dev;netif_oper_up — test if device is operational
int netif_oper_up ( | dev); |
const struct net_device * dev;phy_print_status — Convenience function to print out the current phy status
void phy_print_status ( | phydev); |
struct phy_device * phydev;phy_ethtool_sset — generic ethtool sset function, handles all the details
int phy_ethtool_sset ( | phydev, | |
cmd); |
struct phy_device * phydev;struct ethtool_cmd * cmd;phy_mii_ioctl — generic PHY MII ioctl interface
int phy_mii_ioctl ( | phydev, | |
| ifr, | ||
cmd); |
struct phy_device * phydev;struct ifreq * ifr;int cmd;phy_start_aneg — start auto-negotiation for this PHY device
int phy_start_aneg ( | phydev); |
struct phy_device * phydev;phy_start_interrupts — request and enable interrupts for a PHY device
int phy_start_interrupts ( | phydev); |
struct phy_device * phydev;phy_stop_interrupts — disable interrupts from a PHY device
int phy_stop_interrupts ( | phydev); |
struct phy_device * phydev;phy_stop — Bring down the PHY link, and stop checking the status
void phy_stop ( | phydev); |
struct phy_device * phydev;phy_start — start or restart a PHY device
void phy_start ( | phydev); |
struct phy_device * phydev;phy_clear_interrupt — Ack the phy device's interrupt
int phy_clear_interrupt ( | phydev); |
struct phy_device * phydev;phy_config_interrupt — configure the PHY device for the requested interrupts
int phy_config_interrupt ( | phydev, | |
interrupts); |
struct phy_device * phydev;u32 interrupts;phy_aneg_done — return auto-negotiation status
int phy_aneg_done ( | phydev); |
struct phy_device * phydev;phy_find_setting — find a PHY settings array entry that matches speed & duplex
int phy_find_setting ( | speed, | |
duplex); |
int speed;int duplex;phy_find_valid — find a PHY setting that matches the requested features mask
int phy_find_valid ( | idx, | |
features); |
int idx;u32 features;phy_sanitize_settings — make sure the PHY is set to supported speed and duplex
void phy_sanitize_settings ( | phydev); |
struct phy_device * phydev;phy_start_machine — start PHY state machine tracking
void phy_start_machine ( | phydev, | |
handler); |
struct phy_device * phydev;void (*handler)
(struct net_device *);
The PHY infrastructure can run a state machine
which tracks whether the PHY is starting up, negotiating,
etc. This function starts the timer which tracks the state
of the PHY. If you want to be notified when the state changes,
pass in the callback handler, otherwise, pass NULL. If you
want to maintain your own state machine, do not call this
function.
phy_stop_machine — stop the PHY state machine tracking
void phy_stop_machine ( | phydev); |
struct phy_device * phydev;phy_force_reduction — reduce PHY speed/duplex settings by one step
void phy_force_reduction ( | phydev); |
struct phy_device * phydev;phy_error — enter HALTED state for this PHY device
void phy_error ( | phydev); |
struct phy_device * phydev;phy_interrupt — PHY interrupt handler
irqreturn_t phy_interrupt ( | irq, | |
phy_dat); |
int irq;void * phy_dat;phy_enable_interrupts — Enable the interrupts from the PHY side
int phy_enable_interrupts ( | phydev); |
struct phy_device * phydev;phy_disable_interrupts — Disable the PHY interrupts from the PHY side
int phy_disable_interrupts ( | phydev); |
struct phy_device * phydev;phy_change — Scheduled by the phy_interrupt/timer to handle PHY changes
void phy_change ( | work); |
struct work_struct * work;phy_state_machine — Handle the state machine
void phy_state_machine ( | work); |
struct work_struct * work;get_phy_id — reads the specified addr for its ID.
int get_phy_id ( | bus, | |
| addr, | ||
phy_id); |
struct mii_bus * bus;int addr;u32 * phy_id;get_phy_device —
reads the specified PHY device and returns its phy_device struct
struct phy_device * get_phy_device ( | bus, | |
addr); |
struct mii_bus * bus;int addr;phy_device_register — Register the phy device on the MDIO bus
int phy_device_register ( | phydev); |
struct phy_device * phydev;phy_find_first — finds the first PHY device on the bus
struct phy_device * phy_find_first ( | bus); |
struct mii_bus * bus;phy_connect_direct — connect an ethernet device to a specific phy_device
int phy_connect_direct ( | dev, | |
| phydev, | ||
| handler, | ||
| flags, | ||
interface); |
struct net_device * dev;struct phy_device * phydev;void (*handler)
(struct net_device *);u32 flags;phy_interface_t interface;phy_connect — connect an ethernet device to a PHY device
struct phy_device * phy_connect ( | dev, | |
| bus_id, | ||
| handler, | ||
| flags, | ||
interface); |
struct net_device * dev;const char * bus_id;void (*handler)
(struct net_device *);u32 flags;phy_interface_t interface;devthe network device to connect
bus_idthe id string of the PHY device to connect
handlercallback function for state change notifications
flagsPHY device's dev_flags
interfacePHY device's interface
Convenience function for connecting ethernet devices to PHY devices. The default behavior is for the PHY infrastructure to handle everything, and only notify the connected driver when the link status changes. If you don't want, or can't use the provided functionality, you may choose to call only the subset of functions which provide the desired functionality.
phy_disconnect — disable interrupts, stop state machine, and detach a PHY device
void phy_disconnect ( | phydev); |
struct phy_device * phydev;phy_attach — attach a network device to a particular PHY device
struct phy_device * phy_attach ( | dev, | |
| bus_id, | ||
| flags, | ||
interface); |
struct net_device * dev;const char * bus_id;u32 flags;phy_interface_t interface;phy_detach — detach a PHY device from its network device
void phy_detach ( | phydev); |
struct phy_device * phydev;genphy_restart_aneg — Enable and Restart Autonegotiation
int genphy_restart_aneg ( | phydev); |
struct phy_device * phydev;genphy_config_aneg — restart auto-negotiation or write BMCR
int genphy_config_aneg ( | phydev); |
struct phy_device * phydev;genphy_update_link —
update link status in phydev
int genphy_update_link ( | phydev); |
struct phy_device * phydev;genphy_read_status — check the link status and update current link state
int genphy_read_status ( | phydev); |
struct phy_device * phydev;phy_driver_register — register a phy_driver with the PHY layer
int phy_driver_register ( | new_driver); |
struct phy_driver * new_driver;phy_prepare_link — prepares the PHY layer to monitor link status
void phy_prepare_link ( | phydev, | |
handler); |
struct phy_device * phydev;void (*handler)
(struct net_device *);phy_attach_direct — attach a network device to a given PHY device pointer
int phy_attach_direct ( | dev, | |
| phydev, | ||
| flags, | ||
interface); |
struct net_device * dev;struct phy_device * phydev;u32 flags;phy_interface_t interface;devnetwork device to attach
phydevPointer to phy_device to attach
flagsPHY device's dev_flags
interfacePHY device's interface
Called by drivers to attach to a particular PHY device. The phy_device is found, and properly hooked up to the phy_driver. If no driver is attached, then the genphy_driver is used. The phy_device is given a ptr to the attaching device, and given a callback for link status change. The phy_device is returned to the attaching driver.
genphy_config_advert — sanitize and advertise auto-negotiation parameters
int genphy_config_advert ( | phydev); |
struct phy_device * phydev;genphy_setup_forced —
configures/forces speed/duplex from phydev
int genphy_setup_forced ( | phydev); |
struct phy_device * phydev;mdiobus_alloc — allocate a mii_bus structure
struct mii_bus * mdiobus_alloc ( | void); |
void;mdiobus_register — bring up all the PHYs on a given bus and attach them to bus
int mdiobus_register ( | bus); |
struct mii_bus * bus;mdiobus_read — Convenience function for reading a given MII mgmt register
int mdiobus_read ( | bus, | |
| addr, | ||
regnum); |
struct mii_bus * bus;int addr;u32 regnum;mdiobus_write — Convenience function for writing a given MII mgmt register
int mdiobus_write ( | bus, | |
| addr, | ||
| regnum, | ||
val); |
struct mii_bus * bus;int addr;u32 regnum;u16 val;mdiobus_release — mii_bus device release callback
void mdiobus_release ( | d); |
struct device * d;