Deleted Added
full compact
t4_vf.c (306694) t4_vf.c (309560)
1/*-
2 * Copyright (c) 2016 Chelsio Communications, Inc.
3 * All rights reserved.
4 * Written by: John Baldwin <jhb@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2016 Chelsio Communications, Inc.
3 * All rights reserved.
4 * Written by: John Baldwin <jhb@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: stable/11/sys/dev/cxgbe/t4_vf.c 306694 2016-10-04 22:36:36Z jhb $");
29__FBSDID("$FreeBSD: stable/11/sys/dev/cxgbe/t4_vf.c 309560 2016-12-05 20:43:25Z jhb $");
30
31#include "opt_inet.h"
32#include "opt_inet6.h"
33
34#include <sys/param.h>
35#include <sys/bus.h>
36#include <sys/conf.h>
37#include <sys/kernel.h>

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

106 {0x5805, "Chelsio T540-BCH VF"},
107 {0x5806, "Chelsio T540-CH VF"},
108 {0x5808, "Chelsio T520-CX VF"},
109 {0x580b, "Chelsio B520-SR VF"},
110 {0x580c, "Chelsio B504-BT VF"},
111 {0x580f, "Chelsio Amsterdam VF"},
112 {0x5813, "Chelsio T580-CHR VF"},
113#endif
30
31#include "opt_inet.h"
32#include "opt_inet6.h"
33
34#include <sys/param.h>
35#include <sys/bus.h>
36#include <sys/conf.h>
37#include <sys/kernel.h>

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

106 {0x5805, "Chelsio T540-BCH VF"},
107 {0x5806, "Chelsio T540-CH VF"},
108 {0x5808, "Chelsio T520-CX VF"},
109 {0x580b, "Chelsio B520-SR VF"},
110 {0x580c, "Chelsio B504-BT VF"},
111 {0x580f, "Chelsio Amsterdam VF"},
112 {0x5813, "Chelsio T580-CHR VF"},
113#endif
114}, t6vf_pciids[] = {
115 {0x6801, "Chelsio T6225-CR VF"}, /* 2 x 10/25G */
116 {0x6802, "Chelsio T6225-SO-CR VF"}, /* 2 x 10/25G, nomem */
117 {0x6807, "Chelsio T62100-LP-CR VF"}, /* 2 x 40/50/100G */
118 {0x6808, "Chelsio T62100-SO-CR VF"}, /* 2 x 40/50/100G, nomem */
119 {0x680d, "Chelsio T62100-CR VF"}, /* 2 x 40/50/100G */
114};
115
116static d_ioctl_t t4vf_ioctl;
117
118static struct cdevsw t4vf_cdevsw = {
119 .d_version = D_VERSION,
120 .d_ioctl = t4vf_ioctl,
121 .d_name = "t4vf",

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

148 if (d == t5vf_pciids[i].device) {
149 device_set_desc(dev, t5vf_pciids[i].desc);
150 return (BUS_PROBE_DEFAULT);
151 }
152 }
153 return (ENXIO);
154}
155
120};
121
122static d_ioctl_t t4vf_ioctl;
123
124static struct cdevsw t4vf_cdevsw = {
125 .d_version = D_VERSION,
126 .d_ioctl = t4vf_ioctl,
127 .d_name = "t4vf",

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

154 if (d == t5vf_pciids[i].device) {
155 device_set_desc(dev, t5vf_pciids[i].desc);
156 return (BUS_PROBE_DEFAULT);
157 }
158 }
159 return (ENXIO);
160}
161
162static int
163t6vf_probe(device_t dev)
164{
165 uint16_t d;
166 size_t i;
167
168 d = pci_get_device(dev);
169 for (i = 0; i < nitems(t6vf_pciids); i++) {
170 if (d == t6vf_pciids[i].device) {
171 device_set_desc(dev, t6vf_pciids[i].desc);
172 return (BUS_PROBE_DEFAULT);
173 }
174 }
175 return (ENXIO);
176}
177
156#define FW_PARAM_DEV(param) \
157 (V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | \
158 V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_##param))
159#define FW_PARAM_PFVF(param) \
160 (V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_PFVF) | \
161 V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_PFVF_##param))
162
163static int

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

493 rc = t4_map_bars_0_and_4(sc);
494 if (rc != 0)
495 goto done; /* error message displayed already */
496
497 rc = -t4vf_prep_adapter(sc);
498 if (rc != 0)
499 goto done;
500
178#define FW_PARAM_DEV(param) \
179 (V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | \
180 V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_##param))
181#define FW_PARAM_PFVF(param) \
182 (V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_PFVF) | \
183 V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_PFVF_##param))
184
185static int

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

515 rc = t4_map_bars_0_and_4(sc);
516 if (rc != 0)
517 goto done; /* error message displayed already */
518
519 rc = -t4vf_prep_adapter(sc);
520 if (rc != 0)
521 goto done;
522
523 t4_init_devnames(sc);
524 if (sc->names == NULL) {
525 rc = ENOTSUP;
526 goto done; /* error message displayed already */
527 }
528
501 /*
502 * Leave the 'pf' and 'mbox' values as zero. This ensures
503 * that various firmware messages do not set the fields which
504 * is the correct thing to do for a VF.
505 */
506
507 memset(sc->chan_map, 0xff, sizeof(sc->chan_map));
508

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

629 snprintf(pi->lockname, sizeof(pi->lockname), "%sp%d",
630 device_get_nameunit(dev), i);
631 mtx_init(&pi->pi_lock, pi->lockname, 0, MTX_DEF);
632 sc->chan_map[pi->tx_chan] = i;
633
634 pi->tc = malloc(sizeof(struct tx_sched_class) *
635 sc->chip_params->nsched_cls, M_CXGBE, M_ZERO | M_WAITOK);
636
529 /*
530 * Leave the 'pf' and 'mbox' values as zero. This ensures
531 * that various firmware messages do not set the fields which
532 * is the correct thing to do for a VF.
533 */
534
535 memset(sc->chan_map, 0xff, sizeof(sc->chan_map));
536

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

657 snprintf(pi->lockname, sizeof(pi->lockname), "%sp%d",
658 device_get_nameunit(dev), i);
659 mtx_init(&pi->pi_lock, pi->lockname, 0, MTX_DEF);
660 sc->chan_map[pi->tx_chan] = i;
661
662 pi->tc = malloc(sizeof(struct tx_sched_class) *
663 sc->chip_params->nsched_cls, M_CXGBE, M_ZERO | M_WAITOK);
664
637 if (is_10G_port(pi) || is_40G_port(pi)) {
665 if (port_top_speed(pi) >= 10) {
638 n10g++;
639 } else {
640 n1g++;
641 }
642
643 pi->linkdnrc = -1;
644
666 n10g++;
667 } else {
668 n1g++;
669 }
670
671 pi->linkdnrc = -1;
672
645 pi->dev = device_add_child(dev, is_t4(sc) ? "cxgbev" : "cxlv",
646 -1);
673 pi->dev = device_add_child(dev, sc->names->vf_ifnet_name, -1);
647 if (pi->dev == NULL) {
648 device_printf(dev,
649 "failed to add device for port %d.\n", i);
650 rc = ENXIO;
651 goto done;
652 }
653 pi->vi[0].dev = pi->dev;
654 device_set_softc(pi->dev, pi);

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

697
698 for_each_vi(pi, j, vi) {
699 vi->pi = pi;
700 vi->qsize_rxq = t4_qsize_rxq;
701 vi->qsize_txq = t4_qsize_txq;
702
703 vi->first_rxq = rqidx;
704 vi->first_txq = tqidx;
674 if (pi->dev == NULL) {
675 device_printf(dev,
676 "failed to add device for port %d.\n", i);
677 rc = ENXIO;
678 goto done;
679 }
680 pi->vi[0].dev = pi->dev;
681 device_set_softc(pi->dev, pi);

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

724
725 for_each_vi(pi, j, vi) {
726 vi->pi = pi;
727 vi->qsize_rxq = t4_qsize_rxq;
728 vi->qsize_txq = t4_qsize_txq;
729
730 vi->first_rxq = rqidx;
731 vi->first_txq = tqidx;
705 if (is_10G_port(pi) || is_40G_port(pi)) {
732 if (port_top_speed(pi) >= 10) {
706 vi->tmr_idx = t4_tmr_idx_10g;
707 vi->pktc_idx = t4_pktc_idx_10g;
708 vi->flags |= iaq.intr_flags_10g & INTR_RXQ;
709 vi->nrxq = j == 0 ? iaq.nrxq10g : 1;
710 vi->ntxq = j == 0 ? iaq.ntxq10g : 1;
711 } else {
712 vi->tmr_idx = t4_tmr_idx_1g;
713 vi->pktc_idx = t4_pktc_idx_1g;

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

915};
916
917static driver_t t5vf_driver = {
918 "t5vf",
919 t5vf_methods,
920 sizeof(struct adapter)
921};
922
733 vi->tmr_idx = t4_tmr_idx_10g;
734 vi->pktc_idx = t4_pktc_idx_10g;
735 vi->flags |= iaq.intr_flags_10g & INTR_RXQ;
736 vi->nrxq = j == 0 ? iaq.nrxq10g : 1;
737 vi->ntxq = j == 0 ? iaq.ntxq10g : 1;
738 } else {
739 vi->tmr_idx = t4_tmr_idx_1g;
740 vi->pktc_idx = t4_pktc_idx_1g;

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

942};
943
944static driver_t t5vf_driver = {
945 "t5vf",
946 t5vf_methods,
947 sizeof(struct adapter)
948};
949
950static device_method_t t6vf_methods[] = {
951 DEVMETHOD(device_probe, t6vf_probe),
952 DEVMETHOD(device_attach, t4vf_attach),
953 DEVMETHOD(device_detach, t4_detach_common),
954
955 DEVMETHOD_END
956};
957
958static driver_t t6vf_driver = {
959 "t6vf",
960 t6vf_methods,
961 sizeof(struct adapter)
962};
963
923static driver_t cxgbev_driver = {
924 "cxgbev",
925 cxgbe_methods,
926 sizeof(struct port_info)
927};
928
929static driver_t cxlv_driver = {
930 "cxlv",
931 cxgbe_methods,
932 sizeof(struct port_info)
933};
934
964static driver_t cxgbev_driver = {
965 "cxgbev",
966 cxgbe_methods,
967 sizeof(struct port_info)
968};
969
970static driver_t cxlv_driver = {
971 "cxlv",
972 cxgbe_methods,
973 sizeof(struct port_info)
974};
975
935static devclass_t t4vf_devclass, t5vf_devclass;
936static devclass_t cxgbev_devclass, cxlv_devclass;
976static driver_t ccv_driver = {
977 "ccv",
978 cxgbe_methods,
979 sizeof(struct port_info)
980};
937
981
982static devclass_t t4vf_devclass, t5vf_devclass, t6vf_devclass;
983static devclass_t cxgbev_devclass, cxlv_devclass, ccv_devclass;
984
938DRIVER_MODULE(t4vf, pci, t4vf_driver, t4vf_devclass, 0, 0);
939MODULE_VERSION(t4vf, 1);
940MODULE_DEPEND(t4vf, t4nex, 1, 1, 1);
941
942DRIVER_MODULE(t5vf, pci, t5vf_driver, t5vf_devclass, 0, 0);
943MODULE_VERSION(t5vf, 1);
944MODULE_DEPEND(t5vf, t5nex, 1, 1, 1);
945
985DRIVER_MODULE(t4vf, pci, t4vf_driver, t4vf_devclass, 0, 0);
986MODULE_VERSION(t4vf, 1);
987MODULE_DEPEND(t4vf, t4nex, 1, 1, 1);
988
989DRIVER_MODULE(t5vf, pci, t5vf_driver, t5vf_devclass, 0, 0);
990MODULE_VERSION(t5vf, 1);
991MODULE_DEPEND(t5vf, t5nex, 1, 1, 1);
992
993DRIVER_MODULE(t6vf, pci, t6vf_driver, t6vf_devclass, 0, 0);
994MODULE_VERSION(t6vf, 1);
995MODULE_DEPEND(t6vf, t6nex, 1, 1, 1);
996
946DRIVER_MODULE(cxgbev, t4vf, cxgbev_driver, cxgbev_devclass, 0, 0);
947MODULE_VERSION(cxgbev, 1);
948
949DRIVER_MODULE(cxlv, t5vf, cxlv_driver, cxlv_devclass, 0, 0);
950MODULE_VERSION(cxlv, 1);
997DRIVER_MODULE(cxgbev, t4vf, cxgbev_driver, cxgbev_devclass, 0, 0);
998MODULE_VERSION(cxgbev, 1);
999
1000DRIVER_MODULE(cxlv, t5vf, cxlv_driver, cxlv_devclass, 0, 0);
1001MODULE_VERSION(cxlv, 1);
1002
1003DRIVER_MODULE(ccv, t6vf, ccv_driver, ccv_devclass, 0, 0);
1004MODULE_VERSION(ccv, 1);