Deleted Added
full compact
nicvf_main.c (289551) nicvf_main.c (296030)
1/*
2 * Copyright (C) 2015 Cavium Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*
2 * Copyright (C) 2015 Cavium Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/dev/vnic/nicvf_main.c 289551 2015-10-18 22:02:58Z zbb $
26 * $FreeBSD: head/sys/dev/vnic/nicvf_main.c 296030 2016-02-25 14:12:51Z zbb $
27 *
28 */
29#include <sys/cdefs.h>
27 *
28 */
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/vnic/nicvf_main.c 289551 2015-10-18 22:02:58Z zbb $");
30__FBSDID("$FreeBSD: head/sys/dev/vnic/nicvf_main.c 296030 2016-02-25 14:12:51Z zbb $");
31
32#include "opt_inet.h"
33#include "opt_inet6.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/bitset.h>
38#include <sys/bitstring.h>

--- 309 unchanged lines hidden (view full) ---

348 if_setgetcounterfn(ifp, nicvf_if_getcounter);
349
350 /* Set send queue len to number to default maximum */
351 if_setsendqlen(ifp, IFQ_MAXLEN);
352 if_setsendqready(ifp);
353 if_setmtu(ifp, ETHERMTU);
354
355 if_setcapabilities(ifp, IFCAP_VLAN_MTU);
31
32#include "opt_inet.h"
33#include "opt_inet6.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/bitset.h>
38#include <sys/bitstring.h>

--- 309 unchanged lines hidden (view full) ---

348 if_setgetcounterfn(ifp, nicvf_if_getcounter);
349
350 /* Set send queue len to number to default maximum */
351 if_setsendqlen(ifp, IFQ_MAXLEN);
352 if_setsendqready(ifp);
353 if_setmtu(ifp, ETHERMTU);
354
355 if_setcapabilities(ifp, IFCAP_VLAN_MTU);
356 /*
357 * HW offload capabilities
358 */
359 /* IP/TCP/UDP HW checksums */
360 if_setcapabilitiesbit(ifp, IFCAP_HWCSUM, 0);
361 if_sethwassistbits(ifp, (CSUM_IP | CSUM_TCP | CSUM_UDP), 0);
362
356#ifdef DEVICE_POLLING
357#error "DEVICE_POLLING not supported in VNIC driver yet"
358 if_setcapabilitiesbit(ifp, IFCAP_POLLING, 0);
359#endif
360 if_setcapenable(ifp, if_getcapabilities(ifp));
361 if_setmtu(ifp, ETHERMTU);
362
363 return (0);

--- 131 unchanged lines hidden (view full) ---

495 break;
496
497 case SIOCSIFCAP:
498 mask = ifp->if_capenable ^ ifr->ifr_reqcap;
499 if (mask & IFCAP_VLAN_MTU) {
500 /* No work to do except acknowledge the change took. */
501 ifp->if_capenable ^= IFCAP_VLAN_MTU;
502 }
363#ifdef DEVICE_POLLING
364#error "DEVICE_POLLING not supported in VNIC driver yet"
365 if_setcapabilitiesbit(ifp, IFCAP_POLLING, 0);
366#endif
367 if_setcapenable(ifp, if_getcapabilities(ifp));
368 if_setmtu(ifp, ETHERMTU);
369
370 return (0);

--- 131 unchanged lines hidden (view full) ---

502 break;
503
504 case SIOCSIFCAP:
505 mask = ifp->if_capenable ^ ifr->ifr_reqcap;
506 if (mask & IFCAP_VLAN_MTU) {
507 /* No work to do except acknowledge the change took. */
508 ifp->if_capenable ^= IFCAP_VLAN_MTU;
509 }
510 if (mask & IFCAP_TXCSUM)
511 ifp->if_capenable ^= IFCAP_TXCSUM;
512 if (mask & IFCAP_RXCSUM)
513 ifp->if_capenable ^= IFCAP_RXCSUM;
503 break;
504
505 default:
506 err = ether_ioctl(ifp, cmd, data);
507 break;
508 }
509
510 return (err);

--- 75 unchanged lines hidden (view full) ---

586}
587
588static int
589nicvf_if_transmit(struct ifnet *ifp, struct mbuf *mbuf)
590{
591 struct nicvf *nic = if_getsoftc(ifp);
592 struct queue_set *qs = nic->qs;
593 struct snd_queue *sq;
514 break;
515
516 default:
517 err = ether_ioctl(ifp, cmd, data);
518 break;
519 }
520
521 return (err);

--- 75 unchanged lines hidden (view full) ---

597}
598
599static int
600nicvf_if_transmit(struct ifnet *ifp, struct mbuf *mbuf)
601{
602 struct nicvf *nic = if_getsoftc(ifp);
603 struct queue_set *qs = nic->qs;
604 struct snd_queue *sq;
605 struct mbuf *mtmp;
594 int qidx;
595 int err = 0;
596
597
598 if (__predict_false(qs == NULL)) {
599 panic("%s: missing queue set for %s", __func__,
600 device_get_nameunit(nic->dev));
601 }
602
603 /* Select queue */
604 if (M_HASHTYPE_GET(mbuf) != M_HASHTYPE_NONE)
605 qidx = mbuf->m_pkthdr.flowid % qs->sq_cnt;
606 else
607 qidx = curcpu % qs->sq_cnt;
608
609 sq = &qs->sq[qidx];
610
611 if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
612 IFF_DRV_RUNNING) {
606 int qidx;
607 int err = 0;
608
609
610 if (__predict_false(qs == NULL)) {
611 panic("%s: missing queue set for %s", __func__,
612 device_get_nameunit(nic->dev));
613 }
614
615 /* Select queue */
616 if (M_HASHTYPE_GET(mbuf) != M_HASHTYPE_NONE)
617 qidx = mbuf->m_pkthdr.flowid % qs->sq_cnt;
618 else
619 qidx = curcpu % qs->sq_cnt;
620
621 sq = &qs->sq[qidx];
622
623 if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
624 IFF_DRV_RUNNING) {
613 if (mbuf != NULL)
614 err = drbr_enqueue(ifp, sq->br, mbuf);
625 err = drbr_enqueue(ifp, sq->br, mbuf);
615 return (err);
616 }
617
626 return (err);
627 }
628
618 if (mbuf != NULL) {
629 if (mbuf->m_next != NULL &&
630 (mbuf->m_pkthdr.csum_flags &
631 (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_SCTP)) != 0) {
632 if (M_WRITABLE(mbuf) == 0) {
633 mtmp = m_dup(mbuf, M_NOWAIT);
634 m_freem(mbuf);
635 if (mtmp == NULL)
636 return (ENOBUFS);
637 mbuf = mtmp;
638 }
639 }
619 err = drbr_enqueue(ifp, sq->br, mbuf);
620 if (err != 0)
621 return (err);
640 err = drbr_enqueue(ifp, sq->br, mbuf);
641 if (err != 0)
642 return (err);
622 }
623
624 taskqueue_enqueue(sq->snd_taskq, &sq->snd_task);
625
626 return (0);
627}
628
629static void
630nicvf_if_qflush(struct ifnet *ifp)

--- 793 unchanged lines hidden ---
643
644 taskqueue_enqueue(sq->snd_taskq, &sq->snd_task);
645
646 return (0);
647}
648
649static void
650nicvf_if_qflush(struct ifnet *ifp)

--- 793 unchanged lines hidden ---