Deleted Added
full compact
t4_main.c (345040) t4_main.c (345664)
1/*-
2 * Copyright (c) 2011 Chelsio Communications, Inc.
3 * All rights reserved.
4 * Written by: Navdeep Parhar <np@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) 2011 Chelsio Communications, Inc.
3 * All rights reserved.
4 * Written by: Navdeep Parhar <np@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_main.c 345040 2019-03-11 23:16:10Z jhb $");
29__FBSDID("$FreeBSD: stable/11/sys/dev/cxgbe/t4_main.c 345664 2019-03-28 23:43:38Z jhb $");
30
31#include "opt_ddb.h"
32#include "opt_inet.h"
33#include "opt_inet6.h"
34#include "opt_rss.h"
35
36#include <sys/param.h>
37#include <sys/conf.h>

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

61#include <net/rss_config.h>
62#endif
63#if defined(__i386__) || defined(__amd64__)
64#include <machine/md_var.h>
65#include <machine/cputypes.h>
66#include <vm/vm.h>
67#include <vm/pmap.h>
68#endif
30
31#include "opt_ddb.h"
32#include "opt_inet.h"
33#include "opt_inet6.h"
34#include "opt_rss.h"
35
36#include <sys/param.h>
37#include <sys/conf.h>

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

61#include <net/rss_config.h>
62#endif
63#if defined(__i386__) || defined(__amd64__)
64#include <machine/md_var.h>
65#include <machine/cputypes.h>
66#include <vm/vm.h>
67#include <vm/pmap.h>
68#endif
69#include <crypto/rijndael/rijndael.h>
69#ifdef DDB
70#include <ddb/ddb.h>
71#include <ddb/db_lex.h>
72#endif
73
74#include "common/common.h"
75#include "common/t4_msg.h"
76#include "common/t4_regs.h"

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

662static int sysctl_tp_la_mask(SYSCTL_HANDLER_ARGS);
663static int sysctl_tp_la(SYSCTL_HANDLER_ARGS);
664static int sysctl_tx_rate(SYSCTL_HANDLER_ARGS);
665static int sysctl_ulprx_la(SYSCTL_HANDLER_ARGS);
666static int sysctl_wcwr_stats(SYSCTL_HANDLER_ARGS);
667static int sysctl_tc_params(SYSCTL_HANDLER_ARGS);
668#endif
669#ifdef TCP_OFFLOAD
70#ifdef DDB
71#include <ddb/ddb.h>
72#include <ddb/db_lex.h>
73#endif
74
75#include "common/common.h"
76#include "common/t4_msg.h"
77#include "common/t4_regs.h"

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

663static int sysctl_tp_la_mask(SYSCTL_HANDLER_ARGS);
664static int sysctl_tp_la(SYSCTL_HANDLER_ARGS);
665static int sysctl_tx_rate(SYSCTL_HANDLER_ARGS);
666static int sysctl_ulprx_la(SYSCTL_HANDLER_ARGS);
667static int sysctl_wcwr_stats(SYSCTL_HANDLER_ARGS);
668static int sysctl_tc_params(SYSCTL_HANDLER_ARGS);
669#endif
670#ifdef TCP_OFFLOAD
671static int sysctl_tls_rx_ports(SYSCTL_HANDLER_ARGS);
670static int sysctl_tp_tick(SYSCTL_HANDLER_ARGS);
671static int sysctl_tp_dack_timer(SYSCTL_HANDLER_ARGS);
672static int sysctl_tp_timer(SYSCTL_HANDLER_ARGS);
673static int sysctl_tp_shift_cnt(SYSCTL_HANDLER_ARGS);
674static int sysctl_tp_backoff(SYSCTL_HANDLER_ARGS);
675static int sysctl_holdoff_tmr_idx_ofld(SYSCTL_HANDLER_ARGS);
676static int sysctl_holdoff_pktc_idx_ofld(SYSCTL_HANDLER_ARGS);
677#endif

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

1210 s->eqmap = malloc(s->neq * sizeof(struct sge_eq *), M_CXGBE,
1211 M_ZERO | M_WAITOK);
1212
1213 sc->irq = malloc(sc->intr_count * sizeof(struct irq), M_CXGBE,
1214 M_ZERO | M_WAITOK);
1215
1216 t4_init_l2t(sc, M_WAITOK);
1217 t4_init_tx_sched(sc);
672static int sysctl_tp_tick(SYSCTL_HANDLER_ARGS);
673static int sysctl_tp_dack_timer(SYSCTL_HANDLER_ARGS);
674static int sysctl_tp_timer(SYSCTL_HANDLER_ARGS);
675static int sysctl_tp_shift_cnt(SYSCTL_HANDLER_ARGS);
676static int sysctl_tp_backoff(SYSCTL_HANDLER_ARGS);
677static int sysctl_holdoff_tmr_idx_ofld(SYSCTL_HANDLER_ARGS);
678static int sysctl_holdoff_pktc_idx_ofld(SYSCTL_HANDLER_ARGS);
679#endif

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

1212 s->eqmap = malloc(s->neq * sizeof(struct sge_eq *), M_CXGBE,
1213 M_ZERO | M_WAITOK);
1214
1215 sc->irq = malloc(sc->intr_count * sizeof(struct irq), M_CXGBE,
1216 M_ZERO | M_WAITOK);
1217
1218 t4_init_l2t(sc, M_WAITOK);
1219 t4_init_tx_sched(sc);
1220 if (sc->vres.key.size != 0)
1221 sc->key_map = vmem_create("T4TLS key map", sc->vres.key.start,
1222 sc->vres.key.size, 32, 0, M_FIRSTFIT | M_WAITOK);
1218
1219 /*
1220 * Second pass over the ports. This time we know the number of rx and
1221 * tx queues that each port should get.
1222 */
1223 rqidx = tqidx = 0;
1224#ifdef TCP_OFFLOAD
1225 ofld_rqidx = ofld_tqidx = 0;

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

1494 sc->udbs_res);
1495
1496 if (sc->msix_res)
1497 bus_release_resource(dev, SYS_RES_MEMORY, sc->msix_rid,
1498 sc->msix_res);
1499
1500 if (sc->l2t)
1501 t4_free_l2t(sc->l2t);
1223
1224 /*
1225 * Second pass over the ports. This time we know the number of rx and
1226 * tx queues that each port should get.
1227 */
1228 rqidx = tqidx = 0;
1229#ifdef TCP_OFFLOAD
1230 ofld_rqidx = ofld_tqidx = 0;

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

1499 sc->udbs_res);
1500
1501 if (sc->msix_res)
1502 bus_release_resource(dev, SYS_RES_MEMORY, sc->msix_rid,
1503 sc->msix_res);
1504
1505 if (sc->l2t)
1506 t4_free_l2t(sc->l2t);
1507 if (sc->key_map)
1508 vmem_destroy(sc->key_map);
1502
1503#ifdef TCP_OFFLOAD
1504 free(sc->sge.ofld_rxq, M_CXGBE);
1505 free(sc->sge.ofld_txq, M_CXGBE);
1506#endif
1507#ifdef DEV_NETMAP
1508 free(sc->sge.nm_rxq, M_CXGBE);
1509 free(sc->sge.nm_txq, M_CXGBE);
1510#endif
1511 free(sc->irq, M_CXGBE);
1512 free(sc->sge.rxq, M_CXGBE);
1513 free(sc->sge.txq, M_CXGBE);
1514 free(sc->sge.ctrlq, M_CXGBE);
1515 free(sc->sge.iqmap, M_CXGBE);
1516 free(sc->sge.eqmap, M_CXGBE);
1517 free(sc->tids.ftid_tab, M_CXGBE);
1509
1510#ifdef TCP_OFFLOAD
1511 free(sc->sge.ofld_rxq, M_CXGBE);
1512 free(sc->sge.ofld_txq, M_CXGBE);
1513#endif
1514#ifdef DEV_NETMAP
1515 free(sc->sge.nm_rxq, M_CXGBE);
1516 free(sc->sge.nm_txq, M_CXGBE);
1517#endif
1518 free(sc->irq, M_CXGBE);
1519 free(sc->sge.rxq, M_CXGBE);
1520 free(sc->sge.txq, M_CXGBE);
1521 free(sc->sge.ctrlq, M_CXGBE);
1522 free(sc->sge.iqmap, M_CXGBE);
1523 free(sc->sge.eqmap, M_CXGBE);
1524 free(sc->tids.ftid_tab, M_CXGBE);
1525 free(sc->tt.tls_rx_ports, M_CXGBE);
1518 t4_destroy_dma_tag(sc);
1519 if (mtx_initialized(&sc->sc_lock)) {
1520 sx_xlock(&t4_list_lock);
1521 SLIST_REMOVE(&t4_list, sc, adapter, link);
1522 sx_xunlock(&t4_list_lock);
1523 mtx_destroy(&sc->sc_lock);
1524 }
1525

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

3976 if (rc != 0) {
3977 device_printf(sc->dev,
3978 "failed to query iSCSI parameters: %d.\n", rc);
3979 return (rc);
3980 }
3981 sc->vres.iscsi.start = val[0];
3982 sc->vres.iscsi.size = val[1] - val[0] + 1;
3983 }
1526 t4_destroy_dma_tag(sc);
1527 if (mtx_initialized(&sc->sc_lock)) {
1528 sx_xlock(&t4_list_lock);
1529 SLIST_REMOVE(&t4_list, sc, adapter, link);
1530 sx_xunlock(&t4_list_lock);
1531 mtx_destroy(&sc->sc_lock);
1532 }
1533

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

3984 if (rc != 0) {
3985 device_printf(sc->dev,
3986 "failed to query iSCSI parameters: %d.\n", rc);
3987 return (rc);
3988 }
3989 sc->vres.iscsi.start = val[0];
3990 sc->vres.iscsi.size = val[1] - val[0] + 1;
3991 }
3992 if (sc->cryptocaps & FW_CAPS_CONFIG_TLSKEYS) {
3993 param[0] = FW_PARAM_PFVF(TLS_START);
3994 param[1] = FW_PARAM_PFVF(TLS_END);
3995 rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 2, param, val);
3996 if (rc != 0) {
3997 device_printf(sc->dev,
3998 "failed to query TLS parameters: %d.\n", rc);
3999 return (rc);
4000 }
4001 sc->vres.key.start = val[0];
4002 sc->vres.key.size = val[1] - val[0] + 1;
4003 }
3984
3985 t4_init_sge_params(sc);
3986
3987 /*
3988 * We've got the params we wanted to query via the firmware. Now grab
3989 * some others directly from the chip.
3990 */
3991 rc = t4_read_chip_settings(sc);

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

5775 sc->tt.ddp = 0;
5776 SYSCTL_ADD_INT(ctx, children, OID_AUTO, "ddp", CTLFLAG_RW,
5777 &sc->tt.ddp, 0, "DDP allowed");
5778
5779 sc->tt.rx_coalesce = 1;
5780 SYSCTL_ADD_INT(ctx, children, OID_AUTO, "rx_coalesce",
5781 CTLFLAG_RW, &sc->tt.rx_coalesce, 0, "receive coalescing");
5782
4004
4005 t4_init_sge_params(sc);
4006
4007 /*
4008 * We've got the params we wanted to query via the firmware. Now grab
4009 * some others directly from the chip.
4010 */
4011 rc = t4_read_chip_settings(sc);

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

5795 sc->tt.ddp = 0;
5796 SYSCTL_ADD_INT(ctx, children, OID_AUTO, "ddp", CTLFLAG_RW,
5797 &sc->tt.ddp, 0, "DDP allowed");
5798
5799 sc->tt.rx_coalesce = 1;
5800 SYSCTL_ADD_INT(ctx, children, OID_AUTO, "rx_coalesce",
5801 CTLFLAG_RW, &sc->tt.rx_coalesce, 0, "receive coalescing");
5802
5803 sc->tt.tls = 0;
5804 SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tls", CTLFLAG_RW,
5805 &sc->tt.tls, 0, "Inline TLS allowed");
5806
5807 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "tls_rx_ports",
5808 CTLTYPE_INT | CTLFLAG_RW, sc, 0, sysctl_tls_rx_ports,
5809 "I", "TCP ports that use inline TLS+TOE RX");
5810
5783 sc->tt.tx_align = 1;
5784 SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_align",
5785 CTLFLAG_RW, &sc->tt.tx_align, 0, "chop and align payload");
5786
5787 sc->tt.tx_zcopy = 0;
5788 SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_zcopy",
5789 CTLFLAG_RW, &sc->tt.tx_zcopy, 0,
5790 "Enable zero-copy aio_write(2)");

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

6178 SYSCTL_ADD_T4_PORTSTAT(rx_trunc1,
6179 "# of buffer-group 1 truncated packets");
6180 SYSCTL_ADD_T4_PORTSTAT(rx_trunc2,
6181 "# of buffer-group 2 truncated packets");
6182 SYSCTL_ADD_T4_PORTSTAT(rx_trunc3,
6183 "# of buffer-group 3 truncated packets");
6184
6185#undef SYSCTL_ADD_T4_PORTSTAT
5811 sc->tt.tx_align = 1;
5812 SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_align",
5813 CTLFLAG_RW, &sc->tt.tx_align, 0, "chop and align payload");
5814
5815 sc->tt.tx_zcopy = 0;
5816 SYSCTL_ADD_INT(ctx, children, OID_AUTO, "tx_zcopy",
5817 CTLFLAG_RW, &sc->tt.tx_zcopy, 0,
5818 "Enable zero-copy aio_write(2)");

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

6206 SYSCTL_ADD_T4_PORTSTAT(rx_trunc1,
6207 "# of buffer-group 1 truncated packets");
6208 SYSCTL_ADD_T4_PORTSTAT(rx_trunc2,
6209 "# of buffer-group 2 truncated packets");
6210 SYSCTL_ADD_T4_PORTSTAT(rx_trunc3,
6211 "# of buffer-group 3 truncated packets");
6212
6213#undef SYSCTL_ADD_T4_PORTSTAT
6214
6215 SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "tx_tls_records",
6216 CTLFLAG_RD, &pi->tx_tls_records,
6217 "# of TLS records transmitted");
6218 SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "tx_tls_octets",
6219 CTLFLAG_RD, &pi->tx_tls_octets,
6220 "# of payload octets in transmitted TLS records");
6221 SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "rx_tls_records",
6222 CTLFLAG_RD, &pi->rx_tls_records,
6223 "# of TLS records received");
6224 SYSCTL_ADD_ULONG(ctx, children, OID_AUTO, "rx_tls_octets",
6225 CTLFLAG_RD, &pi->rx_tls_octets,
6226 "# of payload octets in received TLS records");
6186}
6187
6188static int
6189sysctl_int_array(SYSCTL_HANDLER_ARGS)
6190{
6191 int rc, *i, space = 0;
6192 struct sbuf sb;
6193

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

7438 static const char *memory[] = {"EDC0:", "EDC1:", "MC:", "MC0:", "MC1:"};
7439 static const char *region[] = {
7440 "DBQ contexts:", "IMSG contexts:", "FLM cache:", "TCBs:",
7441 "Pstructs:", "Timers:", "Rx FL:", "Tx FL:", "Pstruct FL:",
7442 "Tx payload:", "Rx payload:", "LE hash:", "iSCSI region:",
7443 "TDDP region:", "TPT region:", "STAG region:", "RQ region:",
7444 "RQUDP region:", "PBL region:", "TXPBL region:",
7445 "DBVFIFO region:", "ULPRX state:", "ULPTX state:",
6227}
6228
6229static int
6230sysctl_int_array(SYSCTL_HANDLER_ARGS)
6231{
6232 int rc, *i, space = 0;
6233 struct sbuf sb;
6234

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

7479 static const char *memory[] = {"EDC0:", "EDC1:", "MC:", "MC0:", "MC1:"};
7480 static const char *region[] = {
7481 "DBQ contexts:", "IMSG contexts:", "FLM cache:", "TCBs:",
7482 "Pstructs:", "Timers:", "Rx FL:", "Tx FL:", "Pstruct FL:",
7483 "Tx payload:", "Rx payload:", "LE hash:", "iSCSI region:",
7484 "TDDP region:", "TPT region:", "STAG region:", "RQ region:",
7485 "RQUDP region:", "PBL region:", "TXPBL region:",
7486 "DBVFIFO region:", "ULPRX state:", "ULPTX state:",
7446 "On-chip queues:"
7487 "On-chip queues:", "TLS keys:",
7447 };
7448 struct mem_desc avail[4];
7449 struct mem_desc mem[nitems(region) + 3]; /* up to 3 holes */
7450 struct mem_desc *md = mem;
7451
7452 rc = sysctl_wire_old_buffer(req, 0);
7453 if (rc != 0)
7454 return (rc);

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

7578
7579 md->base = sc->vres.ocq.start;
7580 if (sc->vres.ocq.size)
7581 md->limit = md->base + sc->vres.ocq.size - 1;
7582 else
7583 md->idx = nitems(region); /* hide it */
7584 md++;
7585
7488 };
7489 struct mem_desc avail[4];
7490 struct mem_desc mem[nitems(region) + 3]; /* up to 3 holes */
7491 struct mem_desc *md = mem;
7492
7493 rc = sysctl_wire_old_buffer(req, 0);
7494 if (rc != 0)
7495 return (rc);

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

7619
7620 md->base = sc->vres.ocq.start;
7621 if (sc->vres.ocq.size)
7622 md->limit = md->base + sc->vres.ocq.size - 1;
7623 else
7624 md->idx = nitems(region); /* hide it */
7625 md++;
7626
7627 md->base = sc->vres.key.start;
7628 if (sc->vres.key.size)
7629 md->limit = md->base + sc->vres.key.size - 1;
7630 else
7631 md->idx = nitems(region); /* hide it */
7632 md++;
7633
7586 /* add any address-space holes, there can be up to 3 */
7587 for (n = 0; n < i - 1; n++)
7588 if (avail[n].limit < avail[n + 1].base)
7589 (md++)->base = avail[n].limit;
7590 if (avail[n].limit)
7591 (md++)->base = avail[n].limit;
7592
7593 n = md - mem;

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

8669 rc = sbuf_finish(sb);
8670 sbuf_delete(sb);
8671
8672 return (rc);
8673}
8674#endif
8675
8676#ifdef TCP_OFFLOAD
7634 /* add any address-space holes, there can be up to 3 */
7635 for (n = 0; n < i - 1; n++)
7636 if (avail[n].limit < avail[n + 1].base)
7637 (md++)->base = avail[n].limit;
7638 if (avail[n].limit)
7639 (md++)->base = avail[n].limit;
7640
7641 n = md - mem;

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

8717 rc = sbuf_finish(sb);
8718 sbuf_delete(sb);
8719
8720 return (rc);
8721}
8722#endif
8723
8724#ifdef TCP_OFFLOAD
8725static int
8726sysctl_tls_rx_ports(SYSCTL_HANDLER_ARGS)
8727{
8728 struct adapter *sc = arg1;
8729 int *old_ports, *new_ports;
8730 int i, new_count, rc;
8731
8732 if (req->newptr == NULL && req->oldptr == NULL)
8733 return (SYSCTL_OUT(req, NULL, imax(sc->tt.num_tls_rx_ports, 1) *
8734 sizeof(sc->tt.tls_rx_ports[0])));
8735
8736 rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4tlsrx");
8737 if (rc)
8738 return (rc);
8739
8740 if (sc->tt.num_tls_rx_ports == 0) {
8741 i = -1;
8742 rc = SYSCTL_OUT(req, &i, sizeof(i));
8743 } else
8744 rc = SYSCTL_OUT(req, sc->tt.tls_rx_ports,
8745 sc->tt.num_tls_rx_ports * sizeof(sc->tt.tls_rx_ports[0]));
8746 if (rc == 0 && req->newptr != NULL) {
8747 new_count = req->newlen / sizeof(new_ports[0]);
8748 new_ports = malloc(new_count * sizeof(new_ports[0]), M_CXGBE,
8749 M_WAITOK);
8750 rc = SYSCTL_IN(req, new_ports, new_count *
8751 sizeof(new_ports[0]));
8752 if (rc)
8753 goto err;
8754
8755 /* Allow setting to a single '-1' to clear the list. */
8756 if (new_count == 1 && new_ports[0] == -1) {
8757 ADAPTER_LOCK(sc);
8758 old_ports = sc->tt.tls_rx_ports;
8759 sc->tt.tls_rx_ports = NULL;
8760 sc->tt.num_tls_rx_ports = 0;
8761 ADAPTER_UNLOCK(sc);
8762 free(old_ports, M_CXGBE);
8763 } else {
8764 for (i = 0; i < new_count; i++) {
8765 if (new_ports[i] < 1 ||
8766 new_ports[i] > IPPORT_MAX) {
8767 rc = EINVAL;
8768 goto err;
8769 }
8770 }
8771
8772 ADAPTER_LOCK(sc);
8773 old_ports = sc->tt.tls_rx_ports;
8774 sc->tt.tls_rx_ports = new_ports;
8775 sc->tt.num_tls_rx_ports = new_count;
8776 ADAPTER_UNLOCK(sc);
8777 free(old_ports, M_CXGBE);
8778 new_ports = NULL;
8779 }
8780 err:
8781 free(new_ports, M_CXGBE);
8782 }
8783 end_synchronized_op(sc, 0);
8784 return (rc);
8785}
8786
8677static void
8678unit_conv(char *buf, size_t len, u_int val, u_int factor)
8679{
8680 u_int rem = val % factor;
8681
8682 if (rem == 0)
8683 snprintf(buf, len, "%u", val / factor);
8684 else {

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

10624 db_printf("invalid tid\n");
10625 return;
10626 }
10627
10628 t4_dump_tcb(device_get_softc(dev), tid);
10629}
10630#endif
10631
8787static void
8788unit_conv(char *buf, size_t len, u_int val, u_int factor)
8789{
8790 u_int rem = val % factor;
8791
8792 if (rem == 0)
8793 snprintf(buf, len, "%u", val / factor);
8794 else {

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

10734 db_printf("invalid tid\n");
10735 return;
10736 }
10737
10738 t4_dump_tcb(device_get_softc(dev), tid);
10739}
10740#endif
10741
10742/*
10743 * Borrowed from cesa_prep_aes_key().
10744 *
10745 * NB: The crypto engine wants the words in the decryption key in reverse
10746 * order.
10747 */
10748void
10749t4_aes_getdeckey(void *dec_key, const void *enc_key, unsigned int kbits)
10750{
10751 uint32_t ek[4 * (RIJNDAEL_MAXNR + 1)];
10752 uint32_t *dkey;
10753 int i;
10754
10755 rijndaelKeySetupEnc(ek, enc_key, kbits);
10756 dkey = dec_key;
10757 dkey += (kbits / 8) / 4;
10758
10759 switch (kbits) {
10760 case 128:
10761 for (i = 0; i < 4; i++)
10762 *--dkey = htobe32(ek[4 * 10 + i]);
10763 break;
10764 case 192:
10765 for (i = 0; i < 2; i++)
10766 *--dkey = htobe32(ek[4 * 11 + 2 + i]);
10767 for (i = 0; i < 4; i++)
10768 *--dkey = htobe32(ek[4 * 12 + i]);
10769 break;
10770 case 256:
10771 for (i = 0; i < 4; i++)
10772 *--dkey = htobe32(ek[4 * 13 + i]);
10773 for (i = 0; i < 4; i++)
10774 *--dkey = htobe32(ek[4 * 14 + i]);
10775 break;
10776 }
10777 MPASS(dkey == dec_key);
10778}
10779
10632static struct sx mlu; /* mod load unload */
10633SX_SYSINIT(cxgbe_mlu, &mlu, "cxgbe mod load/unload");
10634
10635static int
10636mod_event(module_t mod, int cmd, void *arg)
10637{
10638 int rc = 0;
10639 static int loaded = 0;

--- 116 unchanged lines hidden ---
10780static struct sx mlu; /* mod load unload */
10781SX_SYSINIT(cxgbe_mlu, &mlu, "cxgbe mod load/unload");
10782
10783static int
10784mod_event(module_t mod, int cmd, void *arg)
10785{
10786 int rc = 0;
10787 static int loaded = 0;

--- 116 unchanged lines hidden ---