本文整理汇总了C++中skb_unlink函数的典型用法代码示例。如果您正苦于以下问题:C++ skb_unlink函数的具体用法?C++ skb_unlink怎么用?C++ skb_unlink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skb_unlink函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bfusb_send_bulk
static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb)
{
struct bfusb_data_scb *scb = (void *) skb->cb;
struct urb *urb = bfusb_get_completed(data);
int err, pipe;
BT_DBG("bfusb %p skb %p len %d", data, skb, skb->len);
if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
return -ENOMEM;
pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep);
usb_fill_bulk_urb(urb, data->udev, pipe, skb->data, skb->len,
bfusb_tx_complete, skb);
scb->urb = urb;
skb_queue_tail(&data->pending_q, skb);
err = usb_submit_urb(urb, GFP_ATOMIC);
if (err) {
BT_ERR("%s bulk tx submit failed urb %p err %d",
data->hdev->name, urb, err);
skb_unlink(skb, &data->pending_q);
usb_free_urb(urb);
} else
atomic_inc(&data->pending_tx);
return err;
}
示例2: bfusb_tx_complete
static void bfusb_tx_complete(struct urb *urb)
{
struct sk_buff *skb = (struct sk_buff *) urb->context;
struct bfusb_data *data = (struct bfusb_data *) skb->dev;
BT_DBG("bfusb %p urb %p skb %p len %d", data, urb, skb, skb->len);
atomic_dec(&data->pending_tx);
if (!test_bit(HCI_RUNNING, &data->hdev->flags))
return;
if (!urb->status)
data->hdev->stat.byte_tx += skb->len;
else
data->hdev->stat.err_tx++;
read_lock(&data->lock);
skb_unlink(skb, &data->pending_q);
skb_queue_tail(&data->completed_q, skb);
bfusb_tx_wakeup(data);
read_unlock(&data->lock);
}
示例3: try_fill_recv
static void try_fill_recv(struct virtnet_info *vi)
{
struct sk_buff *skb;
struct scatterlist sg[1+MAX_SKB_FRAGS];
int num, err;
sg_init_table(sg, 1+MAX_SKB_FRAGS);
for (;;) {
skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN);
if (unlikely(!skb))
break;
skb_put(skb, MAX_PACKET_LEN);
vnet_hdr_to_sg(sg, skb);
num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1;
skb_queue_head(&vi->recv, skb);
err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, num, skb);
if (err) {
skb_unlink(skb, &vi->recv);
kfree_skb(skb);
break;
}
vi->num++;
}
if (unlikely(vi->num > vi->max))
vi->max = vi->num;
vi->rvq->vq_ops->kick(vi->rvq);
}
示例4: start_xmit
static int start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct virtnet_info *vi = netdev_priv(dev);
int num, err;
struct scatterlist sg[1+MAX_SKB_FRAGS];
struct virtio_net_hdr *hdr;
const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest;
DECLARE_MAC_BUF(mac);
sg_init_table(sg, 1+MAX_SKB_FRAGS);
pr_debug("%s: xmit %p %s\n", dev->name, skb, print_mac(mac, dest));
free_old_xmit_skbs(vi);
/* Encode metadata header at front. */
hdr = skb_vnet_hdr(skb);
if (skb->ip_summed == CHECKSUM_PARTIAL) {
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = skb->csum_start - skb_headroom(skb);
hdr->csum_offset = skb->csum_offset;
} else {
hdr->flags = 0;
hdr->csum_offset = hdr->csum_start = 0;
}
if (skb_is_gso(skb)) {
hdr->gso_size = skb_shinfo(skb)->gso_size;
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4_ECN;
else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
else
BUG();
} else {
hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
hdr->gso_size = 0;
}
vnet_hdr_to_sg(sg, skb);
num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1;
__skb_queue_head(&vi->send, skb);
err = vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb);
if (err) {
pr_debug("%s: virtio not prepared to send\n", dev->name);
skb_unlink(skb, &vi->send);
netif_stop_queue(dev);
return NETDEV_TX_BUSY;
}
vi->svq->vq_ops->kick(vi->svq);
return 0;
}
示例5: mesh_nexthop_lookup
/**
* ieee80211s_lookup_nexthop - put the appropriate next hop on a mesh frame
*
* @next_hop: output argument for next hop address
* @skb: frame to be sent
* @dev: network device the frame will be sent through
*
* Returns: 0 if the next hop was found. Nonzero otherwise. If no next hop is
* found, the function will start a path discovery and queue the frame so it is
* sent when the path is resolved. This means the caller must not free the skb
* in this case.
*/
int mesh_nexthop_lookup(u8 *next_hop, struct sk_buff *skb,
struct net_device *dev)
{
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
struct sk_buff *skb_to_free = NULL;
struct mesh_path *mpath;
int err = 0;
rcu_read_lock();
mpath = mesh_path_lookup(skb->data, dev);
if (!mpath) {
mesh_path_add(skb->data, dev);
mpath = mesh_path_lookup(skb->data, dev);
if (!mpath) {
dev_kfree_skb(skb);
sdata->u.sta.mshstats.dropped_frames_no_route++;
err = -ENOSPC;
goto endlookup;
}
}
if (mpath->flags & MESH_PATH_ACTIVE) {
if (time_after(jiffies, mpath->exp_time -
msecs_to_jiffies(sdata->u.sta.mshcfg.path_refresh_time))
&& skb->pkt_type != PACKET_OTHERHOST
&& !(mpath->flags & MESH_PATH_RESOLVING)
&& !(mpath->flags & MESH_PATH_FIXED)) {
mesh_queue_preq(mpath,
PREQ_Q_F_START | PREQ_Q_F_REFRESH);
}
memcpy(next_hop, mpath->next_hop->addr,
ETH_ALEN);
} else {
if (!(mpath->flags & MESH_PATH_RESOLVING)) {
/* Start discovery only if it is not running yet */
mesh_queue_preq(mpath, PREQ_Q_F_START);
}
if (skb_queue_len(&mpath->frame_queue) >=
MESH_FRAME_QUEUE_LEN) {
skb_to_free = mpath->frame_queue.next;
skb_unlink(skb_to_free, &mpath->frame_queue);
}
skb_queue_tail(&mpath->frame_queue, skb);
if (skb_to_free)
mesh_path_discard_frame(skb_to_free, dev);
err = -ENOENT;
}
endlookup:
rcu_read_unlock();
return err;
}
示例6: brcmf_rx_frames
void brcmf_rx_frames(struct device *dev, struct sk_buff_head *skb_list)
{
struct sk_buff *skb, *pnext;
struct brcmf_if *ifp;
struct brcmf_bus *bus_if = dev_get_drvdata(dev);
struct brcmf_pub *drvr = bus_if->drvr;
u8 ifidx;
int ret;
brcmf_dbg(DATA, "Enter\n");
skb_queue_walk_safe(skb_list, skb, pnext) {
skb_unlink(skb, skb_list);
/* process and remove protocol-specific header */
ret = brcmf_proto_hdrpull(drvr, drvr->fw_signals, &ifidx, skb);
ifp = drvr->iflist[ifidx];
if (ret || !ifp || !ifp->ndev) {
if ((ret != -ENODATA) && ifp)
ifp->stats.rx_errors++;
brcmu_pkt_buf_free_skb(skb);
continue;
}
skb->dev = ifp->ndev;
skb->protocol = eth_type_trans(skb, skb->dev);
if (skb->pkt_type == PACKET_MULTICAST)
ifp->stats.multicast++;
/* Process special event packets */
brcmf_fweh_process_skb(drvr, skb);
if (!(ifp->ndev->flags & IFF_UP)) {
brcmu_pkt_buf_free_skb(skb);
continue;
}
ifp->stats.rx_bytes += skb->len;
ifp->stats.rx_packets++;
if (in_interrupt())
netif_rx(skb);
else
/* If the receive is not processed inside an ISR,
* the softirqd must be woken explicitly to service the
* NET_RX_SOFTIRQ. This is handled by netif_rx_ni().
*/
netif_rx_ni(skb);
}
示例7: p54u_rx_cb
static void p54u_rx_cb(struct urb *urb)
{
struct sk_buff *skb = (struct sk_buff *) urb->context;
struct p54u_rx_info *info = (struct p54u_rx_info *)skb->cb;
struct ieee80211_hw *dev = info->dev;
struct p54u_priv *priv = dev->priv;
if (unlikely(urb->status)) {
info->urb = NULL;
usb_free_urb(urb);
return;
}
skb_unlink(skb, &priv->rx_queue);
skb_put(skb, urb->actual_length);
if (!priv->hw_type)
skb_pull(skb, sizeof(struct net2280_tx_hdr));
if (p54_rx(dev, skb)) {
skb = dev_alloc_skb(MAX_RX_SIZE);
if (unlikely(!skb)) {
usb_free_urb(urb);
/* TODO check rx queue length and refill *somewhere* */
return;
}
info = (struct p54u_rx_info *) skb->cb;
info->urb = urb;
info->dev = dev;
urb->transfer_buffer = skb_tail_pointer(skb);
urb->context = skb;
skb_queue_tail(&priv->rx_queue, skb);
} else {
if (!priv->hw_type)
skb_push(skb, sizeof(struct net2280_tx_hdr));
skb_reset_tail_pointer(skb);
skb_trim(skb, 0);
if (urb->transfer_buffer != skb_tail_pointer(skb)) {
/* this should not happen */
WARN_ON(1);
urb->transfer_buffer = skb_tail_pointer(skb);
}
skb_queue_tail(&priv->rx_queue, skb);
}
usb_submit_urb(urb, GFP_ATOMIC);
}
示例8: brcmu_pktq_pflush
void
brcmu_pktq_pflush(struct pktq *pq, int prec, bool dir,
bool (*fn)(struct sk_buff *, void *), void *arg)
{
struct sk_buff_head *q;
struct sk_buff *p, *next;
q = &pq->q[prec].skblist;
skb_queue_walk_safe(q, p, next) {
if (fn == NULL || (*fn) (p, arg)) {
skb_unlink(p, q);
brcmu_pkt_buf_free_skb(p);
pq->len--;
}
}
}
示例9: tx_urb_complete
/**
* tx_urb_complete - completes the execution of an URB
* @urb: a URB
*
* This function is called if the URB has been transferred to a device or an
* error has happened.
*/
static void tx_urb_complete(struct urb *urb)
{
int r;
struct sk_buff *skb;
struct ieee80211_tx_info *info;
struct zd_usb *usb;
struct zd_usb_tx *tx;
skb = (struct sk_buff *)urb->context;
info = IEEE80211_SKB_CB(skb);
/*
* grab 'usb' pointer before handing off the skb (since
* it might be freed by zd_mac_tx_to_dev or mac80211)
*/
usb = &zd_hw_mac(info->rate_driver_data[0])->chip.usb;
tx = &usb->tx;
switch (urb->status) {
case 0:
break;
case -ESHUTDOWN:
case -EINVAL:
case -ENODEV:
case -ENOENT:
case -ECONNRESET:
case -EPIPE:
dev_dbg_f(urb_dev(urb), "urb %p error %d\n", urb, urb->status);
break;
default:
dev_dbg_f(urb_dev(urb), "urb %p error %d\n", urb, urb->status);
goto resubmit;
}
free_urb:
skb_unlink(skb, &usb->tx.submitted_skbs);
zd_mac_tx_to_dev(skb, urb->status);
usb_free_urb(urb);
tx_dec_submitted_urbs(usb);
return;
resubmit:
usb_anchor_urb(urb, &tx->submitted);
r = usb_submit_urb(urb, GFP_ATOMIC);
if (r) {
usb_unanchor_urb(urb);
dev_dbg_f(urb_dev(urb), "error resubmit urb %p %d\n", urb, r);
goto free_urb;
}
}
示例10: shaper_kick
static void shaper_kick(struct shaper *shaper)
{
struct sk_buff *skb;
/*
* Walk the list (may be empty)
*/
while((skb=skb_peek(&shaper->sendq))!=NULL)
{
/*
* Each packet due to go out by now (within an error
* of SHAPER_BURST) gets kicked onto the link
*/
if(sh_debug)
printk("Clock = %ld, jiffies = %ld\n", SHAPERCB(skb)->shapeclock, jiffies);
if(time_before_eq(SHAPERCB(skb)->shapeclock, jiffies + SHAPER_BURST))
{
/*
* Pull the frame and get interrupts back on.
*/
skb_unlink(skb, &shaper->sendq);
if (shaper->recovery <
SHAPERCB(skb)->shapeclock + SHAPERCB(skb)->shapelen)
shaper->recovery = SHAPERCB(skb)->shapeclock + SHAPERCB(skb)->shapelen;
/*
* Pass on to the physical target device via
* our low level packet thrower.
*/
SHAPERCB(skb)->shapepend=0;
shaper_queue_xmit(shaper, skb); /* Fire */
}
else
break;
}
/*
* Next kick.
*/
if(skb!=NULL)
mod_timer(&shaper->timer, SHAPERCB(skb)->shapeclock);
}
示例11: bool
/*
* precedence based dequeue with match function. Passing a NULL pointer
* for the match function parameter is considered to be a wildcard so
* any packet on the queue is returned. In that case it is no different
* from brcmu_pktq_pdeq() above.
*/
struct sk_buff *brcmu_pktq_pdeq_match(struct pktq *pq, int prec,
bool (*match_fn)(struct sk_buff *skb,
void *arg), void *arg)
{
struct sk_buff_head *q;
struct sk_buff *p, *next;
q = &pq->q[prec].skblist;
skb_queue_walk_safe(q, p, next) {
if (match_fn == NULL || match_fn(p, arg)) {
skb_unlink(p, q);
pq->len--;
return p;
}
}
return NULL;
}
示例12: spi_transmit_data
static int spi_transmit_data(struct spi_device *spi,
unsigned char *buf, size_t len)
{
int ret;
struct spi_message msg;
struct spi_transfer t = {
.len = len,
.tx_buf = buf,
.delay_usecs = 10,
};
spi_message_init(&msg);
spi_message_add_tail(&t, &msg);
ret = spi_sync(spi, &msg);
if (ret < 0)
mif_err("spi_sync() fail(%d)\n", ret);
return ret;
}
static int spi_boot_tx_skb(struct link_device *ld, struct io_device *iod,
struct sk_buff *skb)
{
int ret = -EINVAL;
struct spi_boot_link_device *sbld = to_spi_boot_link_dev(ld);
unsigned char *buf = skb->data + SIPC5_MIN_HEADER_SIZE;
int len = skb->len - SIPC5_MIN_HEADER_SIZE;
skb_queue_tail(&sbld->tx_q, skb);
ret = spi_transmit_data(sbld->spi, buf, len);
if (ret < 0) {
mif_err("spi_transmit_data() failed(%d)\n", ret);
goto exit;
}
exit:
skb_unlink(skb, &sbld->tx_q);
return ret;
}
示例13: bfusb_rx_submit
static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb)
{
struct bfusb_data_scb *scb;
struct sk_buff *skb;
int err, pipe, size = HCI_MAX_FRAME_SIZE + 32;
BT_DBG("bfusb %p urb %p", data, urb);
if (!urb) {
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb)
return -ENOMEM;
}
skb = bt_skb_alloc(size, GFP_ATOMIC);
if (!skb) {
usb_free_urb(urb);
return -ENOMEM;
}
skb->dev = (void *) data;
scb = (struct bfusb_data_scb *) skb->cb;
scb->urb = urb;
pipe = usb_rcvbulkpipe(data->udev, data->bulk_in_ep);
usb_fill_bulk_urb(urb, data->udev, pipe, skb->data, size,
bfusb_rx_complete, skb);
skb_queue_tail(&data->pending_q, skb);
err = usb_submit_urb(urb, GFP_ATOMIC);
if (err) {
BT_ERR("%s bulk rx submit failed urb %p err %d",
data->hdev->name, urb, err);
skb_unlink(skb, &data->pending_q);
kfree_skb(skb);
usb_free_urb(urb);
}
return err;
}
示例14: nanopci_read
static ssize_t
nanopci_read(struct file *filp, char __user *buf, size_t count, loff_t *off)
{
struct nano_pci_card *card = filp->private_data;
struct sk_buff *skb;
size_t n;
if(down_interruptible(&card->sem))
return -ERESTARTSYS;
while((skb = skb_peek(&card->rx_queue)) == NULL) {
up(&card->sem);
if(filp->f_flags & O_NONBLOCK)
return -EAGAIN;
if(wait_event_interruptible(card->rx_waitqueue,
!skb_queue_empty(&card->rx_queue)))
return -ERESTARTSYS;
if(down_interruptible(&card->sem))
return -ERESTARTSYS;
}
n = skb->len;
if(n > count)
n = count;
if(copy_to_user(buf, skb->data, n)) {
KDEBUG(ERROR, "EFAULT copying out data");
up(&card->sem);
return -EFAULT;
}
skb_pull(skb, n);
if(skb->len == 0) {
skb_unlink(skb, &card->rx_queue);
dev_kfree_skb(skb);
}
card->status.irq_handled = card->status.irq_count -
skb_queue_len(&card->rx_queue);
up(&card->sem);
return n;
}
示例15: zd_usb_tx
/**
* zd_usb_tx: initiates transfer of a frame of the device
*
* @usb: the zd1211rw-private USB structure
* @skb: a &struct sk_buff pointer
*
* This function tranmits a frame to the device. It doesn't wait for
* completion. The frame must contain the control set and have all the
* control set information available.
*
* The function returns 0 if the transfer has been successfully initiated.
*/
int zd_usb_tx(struct zd_usb *usb, struct sk_buff *skb)
{
int r;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct usb_device *udev = zd_usb_to_usbdev(usb);
struct urb *urb;
struct zd_usb_tx *tx = &usb->tx;
if (!atomic_read(&tx->enabled)) {
r = -ENOENT;
goto out;
}
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) {
r = -ENOMEM;
goto out;
}
usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, EP_DATA_OUT),
skb->data, skb->len, tx_urb_complete, skb);
info->rate_driver_data[1] = (void *)jiffies;
skb_queue_tail(&tx->submitted_skbs, skb);
usb_anchor_urb(urb, &tx->submitted);
r = usb_submit_urb(urb, GFP_ATOMIC);
if (r) {
dev_dbg_f(zd_usb_dev(usb), "error submit urb %p %d\n", urb, r);
usb_unanchor_urb(urb);
skb_unlink(skb, &tx->submitted_skbs);
goto error;
}
tx_inc_submitted_urbs(usb);
return 0;
error:
usb_free_urb(urb);
out:
return r;
}