cfv               142 drivers/net/caif/caif_virtio.c 	struct cfv_info *cfv = vq_tx->vdev->priv;
cfv               144 drivers/net/caif/caif_virtio.c 	++cfv->stats.tx_kicks;
cfv               145 drivers/net/caif/caif_virtio.c 	tasklet_schedule(&cfv->tx_release_tasklet);
cfv               148 drivers/net/caif/caif_virtio.c static void free_buf_info(struct cfv_info *cfv, struct buf_info *buf_info)
cfv               152 drivers/net/caif/caif_virtio.c 	gen_pool_free(cfv->genpool, (unsigned long) buf_info->vaddr,
cfv               162 drivers/net/caif/caif_virtio.c 	struct cfv_info *cfv = vq_tx->vdev->priv;
cfv               165 drivers/net/caif/caif_virtio.c 	BUG_ON(vq_tx != cfv->vq_tx);
cfv               172 drivers/net/caif/caif_virtio.c 		spin_lock_irqsave(&cfv->tx_lock, flags);
cfv               174 drivers/net/caif/caif_virtio.c 		spin_unlock_irqrestore(&cfv->tx_lock, flags);
cfv               180 drivers/net/caif/caif_virtio.c 		free_buf_info(cfv, buf_info);
cfv               186 drivers/net/caif/caif_virtio.c 		if (cfv->vq_tx->num_free <= cfv->watermark_tx)
cfv               190 drivers/net/caif/caif_virtio.c 		if (cfv->reserved_mem == 0 && cfv->genpool)
cfv               191 drivers/net/caif/caif_virtio.c 			cfv->reserved_mem =
cfv               192 drivers/net/caif/caif_virtio.c 				gen_pool_alloc(cfv->genpool,
cfv               193 drivers/net/caif/caif_virtio.c 					       cfv->reserved_size);
cfv               196 drivers/net/caif/caif_virtio.c 		if (cfv->reserved_mem) {
cfv               197 drivers/net/caif/caif_virtio.c 			cfv->watermark_tx =
cfv               198 drivers/net/caif/caif_virtio.c 				virtqueue_get_vring_size(cfv->vq_tx);
cfv               199 drivers/net/caif/caif_virtio.c 			netif_tx_wake_all_queues(cfv->ndev);
cfv               203 drivers/net/caif/caif_virtio.c 			virtqueue_disable_cb(cfv->vq_tx);
cfv               204 drivers/net/caif/caif_virtio.c 			++cfv->stats.tx_flow_on;
cfv               207 drivers/net/caif/caif_virtio.c 			WARN_ON(cfv->watermark_tx >
cfv               208 drivers/net/caif/caif_virtio.c 			       virtqueue_get_vring_size(cfv->vq_tx));
cfv               209 drivers/net/caif/caif_virtio.c 			cfv->watermark_tx +=
cfv               210 drivers/net/caif/caif_virtio.c 				virtqueue_get_vring_size(cfv->vq_tx) / 4;
cfv               217 drivers/net/caif/caif_virtio.c 					      struct cfv_info *cfv,
cfv               225 drivers/net/caif/caif_virtio.c 	if (frm_len > cfv->mru || frm_len <= cfv->rx_hr + cfv->rx_tr) {
cfv               226 drivers/net/caif/caif_virtio.c 		netdev_err(cfv->ndev,
cfv               228 drivers/net/caif/caif_virtio.c 			   frm_len, cfv->mru,  cfv->rx_hr,
cfv               229 drivers/net/caif/caif_virtio.c 			   cfv->rx_tr);
cfv               234 drivers/net/caif/caif_virtio.c 	cfpkt_len = frm_len - (cfv->rx_hr + cfv->rx_tr);
cfv               235 drivers/net/caif/caif_virtio.c 	pad_len = (unsigned long)(frm + cfv->rx_hr) & (IP_HDR_ALIGN - 1);
cfv               237 drivers/net/caif/caif_virtio.c 	skb = netdev_alloc_skb(cfv->ndev, frm_len + pad_len);
cfv               243 drivers/net/caif/caif_virtio.c 	skb_reserve(skb, cfv->rx_hr + pad_len);
cfv               245 drivers/net/caif/caif_virtio.c 	skb_put_data(skb, frm + cfv->rx_hr, cfpkt_len);
cfv               252 drivers/net/caif/caif_virtio.c 	struct cfv_info *cfv = container_of(napi, struct cfv_info, napi);
cfv               257 drivers/net/caif/caif_virtio.c 	struct vringh_kiov *riov = &cfv->ctx.riov;
cfv               267 drivers/net/caif/caif_virtio.c 			if (cfv->ctx.head != USHRT_MAX) {
cfv               268 drivers/net/caif/caif_virtio.c 				vringh_complete_kern(cfv->vr_rx,
cfv               269 drivers/net/caif/caif_virtio.c 						     cfv->ctx.head,
cfv               271 drivers/net/caif/caif_virtio.c 				cfv->ctx.head = USHRT_MAX;
cfv               275 drivers/net/caif/caif_virtio.c 				cfv->vr_rx,
cfv               278 drivers/net/caif/caif_virtio.c 				&cfv->ctx.head,
cfv               288 drivers/net/caif/caif_virtio.c 		skb = cfv_alloc_and_copy_skb(&err, cfv, buf,
cfv               297 drivers/net/caif/caif_virtio.c 		skb->dev = cfv->ndev;
cfv               300 drivers/net/caif/caif_virtio.c 			++cfv->ndev->stats.rx_dropped;
cfv               302 drivers/net/caif/caif_virtio.c 			++cfv->ndev->stats.rx_packets;
cfv               303 drivers/net/caif/caif_virtio.c 			cfv->ndev->stats.rx_bytes += skb_len;
cfv               310 drivers/net/caif/caif_virtio.c 	++cfv->stats.rx_napi_resched;
cfv               316 drivers/net/caif/caif_virtio.c 		++cfv->stats.rx_napi_complete;
cfv               320 drivers/net/caif/caif_virtio.c 		if (unlikely(!vringh_notify_enable_kern(cfv->vr_rx)) &&
cfv               322 drivers/net/caif/caif_virtio.c 			vringh_notify_disable_kern(cfv->vr_rx);
cfv               328 drivers/net/caif/caif_virtio.c 		++cfv->stats.rx_nomem;
cfv               332 drivers/net/caif/caif_virtio.c 		vringh_notify_enable_kern(cfv->vr_rx);
cfv               337 drivers/net/caif/caif_virtio.c 		netdev_warn(cfv->ndev, "Bad ring, disable device\n");
cfv               338 drivers/net/caif/caif_virtio.c 		cfv->ndev->stats.rx_dropped = riov->used - riov->i;
cfv               340 drivers/net/caif/caif_virtio.c 		vringh_notify_disable_kern(cfv->vr_rx);
cfv               341 drivers/net/caif/caif_virtio.c 		netif_carrier_off(cfv->ndev);
cfv               345 drivers/net/caif/caif_virtio.c 	if (rxcnt && vringh_need_notify_kern(cfv->vr_rx) > 0)
cfv               346 drivers/net/caif/caif_virtio.c 		vringh_notify(cfv->vr_rx);
cfv               352 drivers/net/caif/caif_virtio.c 	struct cfv_info *cfv = vdev->priv;
cfv               354 drivers/net/caif/caif_virtio.c 	++cfv->stats.rx_kicks;
cfv               355 drivers/net/caif/caif_virtio.c 	vringh_notify_disable_kern(cfv->vr_rx);
cfv               356 drivers/net/caif/caif_virtio.c 	napi_schedule(&cfv->napi);
cfv               359 drivers/net/caif/caif_virtio.c static void cfv_destroy_genpool(struct cfv_info *cfv)
cfv               361 drivers/net/caif/caif_virtio.c 	if (cfv->alloc_addr)
cfv               362 drivers/net/caif/caif_virtio.c 		dma_free_coherent(cfv->vdev->dev.parent->parent,
cfv               363 drivers/net/caif/caif_virtio.c 				  cfv->allocsz, cfv->alloc_addr,
cfv               364 drivers/net/caif/caif_virtio.c 				  cfv->alloc_dma);
cfv               366 drivers/net/caif/caif_virtio.c 	if (!cfv->genpool)
cfv               368 drivers/net/caif/caif_virtio.c 	gen_pool_free(cfv->genpool,  cfv->reserved_mem,
cfv               369 drivers/net/caif/caif_virtio.c 		      cfv->reserved_size);
cfv               370 drivers/net/caif/caif_virtio.c 	gen_pool_destroy(cfv->genpool);
cfv               371 drivers/net/caif/caif_virtio.c 	cfv->genpool = NULL;
cfv               374 drivers/net/caif/caif_virtio.c static int cfv_create_genpool(struct cfv_info *cfv)
cfv               384 drivers/net/caif/caif_virtio.c 	cfv->allocsz = (virtqueue_get_vring_size(cfv->vq_tx) *
cfv               385 drivers/net/caif/caif_virtio.c 			(ETH_DATA_LEN + cfv->tx_hr + cfv->tx_tr) * 11)/10;
cfv               386 drivers/net/caif/caif_virtio.c 	if (cfv->allocsz <= (num_possible_cpus() + 1) * cfv->ndev->mtu)
cfv               390 drivers/net/caif/caif_virtio.c 		if (cfv->allocsz <= num_possible_cpus() * cfv->ndev->mtu) {
cfv               391 drivers/net/caif/caif_virtio.c 			netdev_info(cfv->ndev, "Not enough device memory\n");
cfv               395 drivers/net/caif/caif_virtio.c 		cfv->alloc_addr = dma_alloc_coherent(
cfv               396 drivers/net/caif/caif_virtio.c 						cfv->vdev->dev.parent->parent,
cfv               397 drivers/net/caif/caif_virtio.c 						cfv->allocsz, &cfv->alloc_dma,
cfv               399 drivers/net/caif/caif_virtio.c 		if (cfv->alloc_addr)
cfv               402 drivers/net/caif/caif_virtio.c 		cfv->allocsz = (cfv->allocsz * 3) >> 2;
cfv               405 drivers/net/caif/caif_virtio.c 	netdev_dbg(cfv->ndev, "Allocated %zd bytes from dma-memory\n",
cfv               406 drivers/net/caif/caif_virtio.c 		   cfv->allocsz);
cfv               409 drivers/net/caif/caif_virtio.c 	cfv->genpool = gen_pool_create(7, -1);
cfv               410 drivers/net/caif/caif_virtio.c 	if (!cfv->genpool)
cfv               413 drivers/net/caif/caif_virtio.c 	err = gen_pool_add_virt(cfv->genpool, (unsigned long)cfv->alloc_addr,
cfv               414 drivers/net/caif/caif_virtio.c 				(phys_addr_t)virt_to_phys(cfv->alloc_addr),
cfv               415 drivers/net/caif/caif_virtio.c 				cfv->allocsz, -1);
cfv               422 drivers/net/caif/caif_virtio.c 	cfv->reserved_size = num_possible_cpus() * cfv->ndev->mtu;
cfv               423 drivers/net/caif/caif_virtio.c 	cfv->reserved_mem = gen_pool_alloc(cfv->genpool,
cfv               424 drivers/net/caif/caif_virtio.c 					   cfv->reserved_size);
cfv               425 drivers/net/caif/caif_virtio.c 	if (!cfv->reserved_mem) {
cfv               430 drivers/net/caif/caif_virtio.c 	cfv->watermark_tx = virtqueue_get_vring_size(cfv->vq_tx);
cfv               433 drivers/net/caif/caif_virtio.c 	cfv_destroy_genpool(cfv);
cfv               440 drivers/net/caif/caif_virtio.c 	struct cfv_info *cfv = netdev_priv(netdev);
cfv               442 drivers/net/caif/caif_virtio.c 	if (cfv_create_genpool(cfv))
cfv               446 drivers/net/caif/caif_virtio.c 	napi_enable(&cfv->napi);
cfv               449 drivers/net/caif/caif_virtio.c 	napi_schedule(&cfv->napi);
cfv               456 drivers/net/caif/caif_virtio.c 	struct cfv_info *cfv = netdev_priv(netdev);
cfv               462 drivers/net/caif/caif_virtio.c 	virtqueue_disable_cb(cfv->vq_tx);
cfv               463 drivers/net/caif/caif_virtio.c 	vringh_notify_disable_kern(cfv->vr_rx);
cfv               464 drivers/net/caif/caif_virtio.c 	napi_disable(&cfv->napi);
cfv               467 drivers/net/caif/caif_virtio.c 	cfv_release_used_buf(cfv->vq_tx);
cfv               468 drivers/net/caif/caif_virtio.c 	spin_lock_irqsave(&cfv->tx_lock, flags);
cfv               469 drivers/net/caif/caif_virtio.c 	while ((buf_info = virtqueue_detach_unused_buf(cfv->vq_tx)))
cfv               470 drivers/net/caif/caif_virtio.c 		free_buf_info(cfv, buf_info);
cfv               471 drivers/net/caif/caif_virtio.c 	spin_unlock_irqrestore(&cfv->tx_lock, flags);
cfv               474 drivers/net/caif/caif_virtio.c 	cfv_destroy_genpool(cfv);
cfv               479 drivers/net/caif/caif_virtio.c static struct buf_info *cfv_alloc_and_copy_to_shm(struct cfv_info *cfv,
cfv               487 drivers/net/caif/caif_virtio.c 	if (!cfv->genpool)
cfv               490 drivers/net/caif/caif_virtio.c 	if (unlikely(cfv->tx_hr + skb->len + cfv->tx_tr > cfv->mtu)) {
cfv               491 drivers/net/caif/caif_virtio.c 		netdev_warn(cfv->ndev, "Invalid packet len (%d > %d)\n",
cfv               492 drivers/net/caif/caif_virtio.c 			    cfv->tx_hr + skb->len + cfv->tx_tr, cfv->mtu);
cfv               501 drivers/net/caif/caif_virtio.c 	hdr_ofs = cfv->tx_hr + info->hdr_len;
cfv               503 drivers/net/caif/caif_virtio.c 	buf_info->size = cfv->tx_hr + skb->len + cfv->tx_tr + pad_len;
cfv               506 drivers/net/caif/caif_virtio.c 	buf_info->vaddr = (void *)gen_pool_alloc(cfv->genpool, buf_info->size);
cfv               511 drivers/net/caif/caif_virtio.c 	skb_copy_bits(skb, 0, buf_info->vaddr + cfv->tx_hr + pad_len, skb->len);
cfv               513 drivers/net/caif/caif_virtio.c 		    skb->len + cfv->tx_hr + cfv->rx_hr);
cfv               524 drivers/net/caif/caif_virtio.c 	struct cfv_info *cfv = netdev_priv(netdev);
cfv               532 drivers/net/caif/caif_virtio.c 	cfv_release_used_buf(cfv->vq_tx);
cfv               533 drivers/net/caif/caif_virtio.c 	spin_lock_irqsave(&cfv->tx_lock, flags);
cfv               540 drivers/net/caif/caif_virtio.c 	if (unlikely(cfv->vq_tx->num_free <= num_present_cpus())) {
cfv               542 drivers/net/caif/caif_virtio.c 		cfv->stats.tx_full_ring++;
cfv               548 drivers/net/caif/caif_virtio.c 	buf_info = cfv_alloc_and_copy_to_shm(cfv, skb, &sg);
cfv               550 drivers/net/caif/caif_virtio.c 		cfv->stats.tx_no_mem++;
cfv               553 drivers/net/caif/caif_virtio.c 		if (cfv->reserved_mem && cfv->genpool) {
cfv               554 drivers/net/caif/caif_virtio.c 			gen_pool_free(cfv->genpool,  cfv->reserved_mem,
cfv               555 drivers/net/caif/caif_virtio.c 				      cfv->reserved_size);
cfv               556 drivers/net/caif/caif_virtio.c 			cfv->reserved_mem = 0;
cfv               557 drivers/net/caif/caif_virtio.c 			buf_info = cfv_alloc_and_copy_to_shm(cfv, skb, &sg);
cfv               563 drivers/net/caif/caif_virtio.c 		cfv->watermark_tx = virtqueue_get_vring_size(cfv->vq_tx) / 4;
cfv               565 drivers/net/caif/caif_virtio.c 		virtqueue_enable_cb(cfv->vq_tx);
cfv               571 drivers/net/caif/caif_virtio.c 		netdev_warn(cfv->ndev, "Out of gen_pool memory\n");
cfv               575 drivers/net/caif/caif_virtio.c 	ret = virtqueue_add_outbuf(cfv->vq_tx, &sg, 1, buf_info, GFP_ATOMIC);
cfv               578 drivers/net/caif/caif_virtio.c 		netdev_warn(cfv->ndev, "Failed adding buffer to TX vring:%d\n",
cfv               584 drivers/net/caif/caif_virtio.c 	cfv->ndev->stats.tx_packets++;
cfv               585 drivers/net/caif/caif_virtio.c 	cfv->ndev->stats.tx_bytes += skb->len;
cfv               586 drivers/net/caif/caif_virtio.c 	spin_unlock_irqrestore(&cfv->tx_lock, flags);
cfv               589 drivers/net/caif/caif_virtio.c 	virtqueue_kick(cfv->vq_tx);
cfv               594 drivers/net/caif/caif_virtio.c 	spin_unlock_irqrestore(&cfv->tx_lock, flags);
cfv               595 drivers/net/caif/caif_virtio.c 	cfv->ndev->stats.tx_dropped++;
cfv               596 drivers/net/caif/caif_virtio.c 	free_buf_info(cfv, buf_info);
cfv               603 drivers/net/caif/caif_virtio.c 	struct cfv_info *cfv = (struct cfv_info *)drv;
cfv               604 drivers/net/caif/caif_virtio.c 	cfv_release_used_buf(cfv->vq_tx);
cfv               624 drivers/net/caif/caif_virtio.c static inline void debugfs_init(struct cfv_info *cfv)
cfv               626 drivers/net/caif/caif_virtio.c 	cfv->debugfs = debugfs_create_dir(netdev_name(cfv->ndev), NULL);
cfv               628 drivers/net/caif/caif_virtio.c 	debugfs_create_u32("rx-napi-complete", 0400, cfv->debugfs,
cfv               629 drivers/net/caif/caif_virtio.c 			   &cfv->stats.rx_napi_complete);
cfv               630 drivers/net/caif/caif_virtio.c 	debugfs_create_u32("rx-napi-resched", 0400, cfv->debugfs,
cfv               631 drivers/net/caif/caif_virtio.c 			   &cfv->stats.rx_napi_resched);
cfv               632 drivers/net/caif/caif_virtio.c 	debugfs_create_u32("rx-nomem", 0400, cfv->debugfs,
cfv               633 drivers/net/caif/caif_virtio.c 			   &cfv->stats.rx_nomem);
cfv               634 drivers/net/caif/caif_virtio.c 	debugfs_create_u32("rx-kicks", 0400, cfv->debugfs,
cfv               635 drivers/net/caif/caif_virtio.c 			   &cfv->stats.rx_kicks);
cfv               636 drivers/net/caif/caif_virtio.c 	debugfs_create_u32("tx-full-ring", 0400, cfv->debugfs,
cfv               637 drivers/net/caif/caif_virtio.c 			   &cfv->stats.tx_full_ring);
cfv               638 drivers/net/caif/caif_virtio.c 	debugfs_create_u32("tx-no-mem", 0400, cfv->debugfs,
cfv               639 drivers/net/caif/caif_virtio.c 			   &cfv->stats.tx_no_mem);
cfv               640 drivers/net/caif/caif_virtio.c 	debugfs_create_u32("tx-kicks", 0400, cfv->debugfs,
cfv               641 drivers/net/caif/caif_virtio.c 			   &cfv->stats.tx_kicks);
cfv               642 drivers/net/caif/caif_virtio.c 	debugfs_create_u32("tx-flow-on", 0400, cfv->debugfs,
cfv               643 drivers/net/caif/caif_virtio.c 			   &cfv->stats.tx_flow_on);
cfv               654 drivers/net/caif/caif_virtio.c 	struct cfv_info *cfv;
cfv               662 drivers/net/caif/caif_virtio.c 	cfv = netdev_priv(netdev);
cfv               663 drivers/net/caif/caif_virtio.c 	cfv->vdev = vdev;
cfv               664 drivers/net/caif/caif_virtio.c 	cfv->ndev = netdev;
cfv               666 drivers/net/caif/caif_virtio.c 	spin_lock_init(&cfv->tx_lock);
cfv               673 drivers/net/caif/caif_virtio.c 	err = vdev->vringh_config->find_vrhs(vdev, 1, &cfv->vr_rx, &vrh_cbs);
cfv               678 drivers/net/caif/caif_virtio.c 	err = virtio_find_vqs(vdev, 1, &cfv->vq_tx, &vq_cbs, &names, NULL);
cfv               685 drivers/net/caif/caif_virtio.c 			     &cfv->tx_hr);
cfv               687 drivers/net/caif/caif_virtio.c 			     &cfv->rx_hr);
cfv               689 drivers/net/caif/caif_virtio.c 			     &cfv->tx_tr);
cfv               691 drivers/net/caif/caif_virtio.c 			     &cfv->rx_tr);
cfv               693 drivers/net/caif/caif_virtio.c 			     &cfv->mtu);
cfv               695 drivers/net/caif/caif_virtio.c 			     &cfv->mru);
cfv               697 drivers/net/caif/caif_virtio.c 		cfv->tx_hr = CFV_DEF_HEADROOM;
cfv               698 drivers/net/caif/caif_virtio.c 		cfv->rx_hr = CFV_DEF_HEADROOM;
cfv               699 drivers/net/caif/caif_virtio.c 		cfv->tx_tr = CFV_DEF_TAILROOM;
cfv               700 drivers/net/caif/caif_virtio.c 		cfv->rx_tr = CFV_DEF_TAILROOM;
cfv               701 drivers/net/caif/caif_virtio.c 		cfv->mtu = CFV_DEF_MTU_SIZE;
cfv               702 drivers/net/caif/caif_virtio.c 		cfv->mru = CFV_DEF_MTU_SIZE;
cfv               705 drivers/net/caif/caif_virtio.c 	netdev->needed_headroom = cfv->tx_hr;
cfv               706 drivers/net/caif/caif_virtio.c 	netdev->needed_tailroom = cfv->tx_tr;
cfv               709 drivers/net/caif/caif_virtio.c 	virtqueue_disable_cb(cfv->vq_tx);
cfv               711 drivers/net/caif/caif_virtio.c 	netdev->mtu = cfv->mtu - cfv->tx_tr;
cfv               712 drivers/net/caif/caif_virtio.c 	vdev->priv = cfv;
cfv               715 drivers/net/caif/caif_virtio.c 	vringh_kiov_init(&cfv->ctx.riov, NULL, 0);
cfv               716 drivers/net/caif/caif_virtio.c 	cfv->ctx.head = USHRT_MAX;
cfv               717 drivers/net/caif/caif_virtio.c 	netif_napi_add(netdev, &cfv->napi, cfv_rx_poll, CFV_DEFAULT_QUOTA);
cfv               719 drivers/net/caif/caif_virtio.c 	tasklet_init(&cfv->tx_release_tasklet,
cfv               721 drivers/net/caif/caif_virtio.c 		     (unsigned long)cfv);
cfv               733 drivers/net/caif/caif_virtio.c 	debugfs_init(cfv);
cfv               737 drivers/net/caif/caif_virtio.c 	netdev_warn(cfv->ndev, "CAIF Virtio probe failed:%d\n", err);
cfv               739 drivers/net/caif/caif_virtio.c 	if (cfv->vr_rx)
cfv               740 drivers/net/caif/caif_virtio.c 		vdev->vringh_config->del_vrhs(cfv->vdev);
cfv               741 drivers/net/caif/caif_virtio.c 	if (cfv->vdev)
cfv               742 drivers/net/caif/caif_virtio.c 		vdev->config->del_vqs(cfv->vdev);
cfv               749 drivers/net/caif/caif_virtio.c 	struct cfv_info *cfv = vdev->priv;
cfv               752 drivers/net/caif/caif_virtio.c 	dev_close(cfv->ndev);
cfv               755 drivers/net/caif/caif_virtio.c 	tasklet_kill(&cfv->tx_release_tasklet);
cfv               756 drivers/net/caif/caif_virtio.c 	debugfs_remove_recursive(cfv->debugfs);
cfv               758 drivers/net/caif/caif_virtio.c 	vringh_kiov_cleanup(&cfv->ctx.riov);
cfv               760 drivers/net/caif/caif_virtio.c 	vdev->vringh_config->del_vrhs(cfv->vdev);
cfv               761 drivers/net/caif/caif_virtio.c 	cfv->vr_rx = NULL;
cfv               762 drivers/net/caif/caif_virtio.c 	vdev->config->del_vqs(cfv->vdev);
cfv               763 drivers/net/caif/caif_virtio.c 	unregister_netdev(cfv->ndev);