diff options
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_driver.c')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_driver.c | 349 |
1 files changed, 242 insertions, 107 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c index f98518d912b5..2108466c7e33 100644 --- a/drivers/infiniband/hw/ipath/ipath_driver.c +++ b/drivers/infiniband/hw/ipath/ipath_driver.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include <linux/vmalloc.h> | 39 | #include <linux/vmalloc.h> |
40 | 40 | ||
41 | #include "ipath_kernel.h" | 41 | #include "ipath_kernel.h" |
42 | #include "ipath_layer.h" | 42 | #include "ipath_verbs.h" |
43 | #include "ipath_common.h" | 43 | #include "ipath_common.h" |
44 | 44 | ||
45 | static void ipath_update_pio_bufs(struct ipath_devdata *); | 45 | static void ipath_update_pio_bufs(struct ipath_devdata *); |
@@ -51,8 +51,6 @@ const char *ipath_get_unit_name(int unit) | |||
51 | return iname; | 51 | return iname; |
52 | } | 52 | } |
53 | 53 | ||
54 | EXPORT_SYMBOL_GPL(ipath_get_unit_name); | ||
55 | |||
56 | #define DRIVER_LOAD_MSG "QLogic " IPATH_DRV_NAME " loaded: " | 54 | #define DRIVER_LOAD_MSG "QLogic " IPATH_DRV_NAME " loaded: " |
57 | #define PFX IPATH_DRV_NAME ": " | 55 | #define PFX IPATH_DRV_NAME ": " |
58 | 56 | ||
@@ -60,13 +58,13 @@ EXPORT_SYMBOL_GPL(ipath_get_unit_name); | |||
60 | * The size has to be longer than this string, so we can append | 58 | * The size has to be longer than this string, so we can append |
61 | * board/chip information to it in the init code. | 59 | * board/chip information to it in the init code. |
62 | */ | 60 | */ |
63 | const char ipath_core_version[] = IPATH_IDSTR "\n"; | 61 | const char ib_ipath_version[] = IPATH_IDSTR "\n"; |
64 | 62 | ||
65 | static struct idr unit_table; | 63 | static struct idr unit_table; |
66 | DEFINE_SPINLOCK(ipath_devs_lock); | 64 | DEFINE_SPINLOCK(ipath_devs_lock); |
67 | LIST_HEAD(ipath_dev_list); | 65 | LIST_HEAD(ipath_dev_list); |
68 | 66 | ||
69 | wait_queue_head_t ipath_sma_state_wait; | 67 | wait_queue_head_t ipath_state_wait; |
70 | 68 | ||
71 | unsigned ipath_debug = __IPATH_INFO; | 69 | unsigned ipath_debug = __IPATH_INFO; |
72 | 70 | ||
@@ -403,10 +401,10 @@ static int __devinit ipath_init_one(struct pci_dev *pdev, | |||
403 | /* setup the chip-specific functions, as early as possible. */ | 401 | /* setup the chip-specific functions, as early as possible. */ |
404 | switch (ent->device) { | 402 | switch (ent->device) { |
405 | case PCI_DEVICE_ID_INFINIPATH_HT: | 403 | case PCI_DEVICE_ID_INFINIPATH_HT: |
406 | ipath_init_ht400_funcs(dd); | 404 | ipath_init_iba6110_funcs(dd); |
407 | break; | 405 | break; |
408 | case PCI_DEVICE_ID_INFINIPATH_PE800: | 406 | case PCI_DEVICE_ID_INFINIPATH_PE800: |
409 | ipath_init_pe800_funcs(dd); | 407 | ipath_init_iba6120_funcs(dd); |
410 | break; | 408 | break; |
411 | default: | 409 | default: |
412 | ipath_dev_err(dd, "Found unknown QLogic deviceid 0x%x, " | 410 | ipath_dev_err(dd, "Found unknown QLogic deviceid 0x%x, " |
@@ -440,7 +438,13 @@ static int __devinit ipath_init_one(struct pci_dev *pdev, | |||
440 | } | 438 | } |
441 | dd->ipath_pcirev = rev; | 439 | dd->ipath_pcirev = rev; |
442 | 440 | ||
441 | #if defined(__powerpc__) | ||
442 | /* There isn't a generic way to specify writethrough mappings */ | ||
443 | dd->ipath_kregbase = __ioremap(addr, len, | ||
444 | (_PAGE_NO_CACHE|_PAGE_WRITETHRU)); | ||
445 | #else | ||
443 | dd->ipath_kregbase = ioremap_nocache(addr, len); | 446 | dd->ipath_kregbase = ioremap_nocache(addr, len); |
447 | #endif | ||
444 | 448 | ||
445 | if (!dd->ipath_kregbase) { | 449 | if (!dd->ipath_kregbase) { |
446 | ipath_dbg("Unable to map io addr %llx to kvirt, failing\n", | 450 | ipath_dbg("Unable to map io addr %llx to kvirt, failing\n", |
@@ -503,7 +507,7 @@ static int __devinit ipath_init_one(struct pci_dev *pdev, | |||
503 | ipathfs_add_device(dd); | 507 | ipathfs_add_device(dd); |
504 | ipath_user_add(dd); | 508 | ipath_user_add(dd); |
505 | ipath_diag_add(dd); | 509 | ipath_diag_add(dd); |
506 | ipath_layer_add(dd); | 510 | ipath_register_ib_device(dd); |
507 | 511 | ||
508 | goto bail; | 512 | goto bail; |
509 | 513 | ||
@@ -532,7 +536,7 @@ static void __devexit ipath_remove_one(struct pci_dev *pdev) | |||
532 | return; | 536 | return; |
533 | 537 | ||
534 | dd = pci_get_drvdata(pdev); | 538 | dd = pci_get_drvdata(pdev); |
535 | ipath_layer_remove(dd); | 539 | ipath_unregister_ib_device(dd->verbs_dev); |
536 | ipath_diag_remove(dd); | 540 | ipath_diag_remove(dd); |
537 | ipath_user_remove(dd); | 541 | ipath_user_remove(dd); |
538 | ipathfs_remove_device(dd); | 542 | ipathfs_remove_device(dd); |
@@ -607,21 +611,23 @@ void ipath_disarm_piobufs(struct ipath_devdata *dd, unsigned first, | |||
607 | * | 611 | * |
608 | * wait up to msecs milliseconds for IB link state change to occur for | 612 | * wait up to msecs milliseconds for IB link state change to occur for |
609 | * now, take the easy polling route. Currently used only by | 613 | * now, take the easy polling route. Currently used only by |
610 | * ipath_layer_set_linkstate. Returns 0 if state reached, otherwise | 614 | * ipath_set_linkstate. Returns 0 if state reached, otherwise |
611 | * -ETIMEDOUT state can have multiple states set, for any of several | 615 | * -ETIMEDOUT state can have multiple states set, for any of several |
612 | * transitions. | 616 | * transitions. |
613 | */ | 617 | */ |
614 | int ipath_wait_linkstate(struct ipath_devdata *dd, u32 state, int msecs) | 618 | static int ipath_wait_linkstate(struct ipath_devdata *dd, u32 state, |
619 | int msecs) | ||
615 | { | 620 | { |
616 | dd->ipath_sma_state_wanted = state; | 621 | dd->ipath_state_wanted = state; |
617 | wait_event_interruptible_timeout(ipath_sma_state_wait, | 622 | wait_event_interruptible_timeout(ipath_state_wait, |
618 | (dd->ipath_flags & state), | 623 | (dd->ipath_flags & state), |
619 | msecs_to_jiffies(msecs)); | 624 | msecs_to_jiffies(msecs)); |
620 | dd->ipath_sma_state_wanted = 0; | 625 | dd->ipath_state_wanted = 0; |
621 | 626 | ||
622 | if (!(dd->ipath_flags & state)) { | 627 | if (!(dd->ipath_flags & state)) { |
623 | u64 val; | 628 | u64 val; |
624 | ipath_cdbg(SMA, "Didn't reach linkstate %s within %u ms\n", | 629 | ipath_cdbg(VERBOSE, "Didn't reach linkstate %s within %u" |
630 | " ms\n", | ||
625 | /* test INIT ahead of DOWN, both can be set */ | 631 | /* test INIT ahead of DOWN, both can be set */ |
626 | (state & IPATH_LINKINIT) ? "INIT" : | 632 | (state & IPATH_LINKINIT) ? "INIT" : |
627 | ((state & IPATH_LINKDOWN) ? "DOWN" : | 633 | ((state & IPATH_LINKDOWN) ? "DOWN" : |
@@ -807,58 +813,6 @@ bail: | |||
807 | return skb; | 813 | return skb; |
808 | } | 814 | } |
809 | 815 | ||
810 | /** | ||
811 | * ipath_rcv_layer - receive a packet for the layered (ethernet) driver | ||
812 | * @dd: the infinipath device | ||
813 | * @etail: the sk_buff number | ||
814 | * @tlen: the total packet length | ||
815 | * @hdr: the ethernet header | ||
816 | * | ||
817 | * Separate routine for better overall optimization | ||
818 | */ | ||
819 | static void ipath_rcv_layer(struct ipath_devdata *dd, u32 etail, | ||
820 | u32 tlen, struct ether_header *hdr) | ||
821 | { | ||
822 | u32 elen; | ||
823 | u8 pad, *bthbytes; | ||
824 | struct sk_buff *skb, *nskb; | ||
825 | |||
826 | if (dd->ipath_port0_skbs && | ||
827 | hdr->sub_opcode == IPATH_ITH4X_OPCODE_ENCAP) { | ||
828 | /* | ||
829 | * Allocate a new sk_buff to replace the one we give | ||
830 | * to the network stack. | ||
831 | */ | ||
832 | nskb = ipath_alloc_skb(dd, GFP_ATOMIC); | ||
833 | if (!nskb) { | ||
834 | /* count OK packets that we drop */ | ||
835 | ipath_stats.sps_krdrops++; | ||
836 | return; | ||
837 | } | ||
838 | |||
839 | bthbytes = (u8 *) hdr->bth; | ||
840 | pad = (bthbytes[1] >> 4) & 3; | ||
841 | /* +CRC32 */ | ||
842 | elen = tlen - (sizeof(*hdr) + pad + sizeof(u32)); | ||
843 | |||
844 | skb = dd->ipath_port0_skbs[etail]; | ||
845 | dd->ipath_port0_skbs[etail] = nskb; | ||
846 | skb_put(skb, elen); | ||
847 | |||
848 | dd->ipath_f_put_tid(dd, etail + (u64 __iomem *) | ||
849 | ((char __iomem *) dd->ipath_kregbase | ||
850 | + dd->ipath_rcvegrbase), 0, | ||
851 | virt_to_phys(nskb->data)); | ||
852 | |||
853 | __ipath_layer_rcv(dd, hdr, skb); | ||
854 | |||
855 | /* another ether packet received */ | ||
856 | ipath_stats.sps_ether_rpkts++; | ||
857 | } | ||
858 | else if (hdr->sub_opcode == IPATH_ITH4X_OPCODE_LID_ARP) | ||
859 | __ipath_layer_rcv_lid(dd, hdr); | ||
860 | } | ||
861 | |||
862 | static void ipath_rcv_hdrerr(struct ipath_devdata *dd, | 816 | static void ipath_rcv_hdrerr(struct ipath_devdata *dd, |
863 | u32 eflags, | 817 | u32 eflags, |
864 | u32 l, | 818 | u32 l, |
@@ -972,26 +926,17 @@ reloop: | |||
972 | if (unlikely(eflags)) | 926 | if (unlikely(eflags)) |
973 | ipath_rcv_hdrerr(dd, eflags, l, etail, rc); | 927 | ipath_rcv_hdrerr(dd, eflags, l, etail, rc); |
974 | else if (etype == RCVHQ_RCV_TYPE_NON_KD) { | 928 | else if (etype == RCVHQ_RCV_TYPE_NON_KD) { |
975 | int ret = __ipath_verbs_rcv(dd, rc + 1, | 929 | ipath_ib_rcv(dd->verbs_dev, rc + 1, ebuf, tlen); |
976 | ebuf, tlen); | 930 | if (dd->ipath_lli_counter) |
977 | if (ret == -ENODEV) | 931 | dd->ipath_lli_counter--; |
978 | ipath_cdbg(VERBOSE, | 932 | ipath_cdbg(PKT, "typ %x, opcode %x (eager, " |
979 | "received IB packet, " | 933 | "qp=%x), len %x; ignored\n", |
980 | "not SMA (QP=%x)\n", qp); | 934 | etype, bthbytes[0], qp, tlen); |
981 | if (dd->ipath_lli_counter) | ||
982 | dd->ipath_lli_counter--; | ||
983 | |||
984 | } else if (etype == RCVHQ_RCV_TYPE_EAGER) { | ||
985 | if (qp == IPATH_KD_QP && | ||
986 | bthbytes[0] == ipath_layer_rcv_opcode && | ||
987 | ebuf) | ||
988 | ipath_rcv_layer(dd, etail, tlen, | ||
989 | (struct ether_header *)hdr); | ||
990 | else | ||
991 | ipath_cdbg(PKT, "typ %x, opcode %x (eager, " | ||
992 | "qp=%x), len %x; ignored\n", | ||
993 | etype, bthbytes[0], qp, tlen); | ||
994 | } | 935 | } |
936 | else if (etype == RCVHQ_RCV_TYPE_EAGER) | ||
937 | ipath_cdbg(PKT, "typ %x, opcode %x (eager, " | ||
938 | "qp=%x), len %x; ignored\n", | ||
939 | etype, bthbytes[0], qp, tlen); | ||
995 | else if (etype == RCVHQ_RCV_TYPE_EXPECTED) | 940 | else if (etype == RCVHQ_RCV_TYPE_EXPECTED) |
996 | ipath_dbg("Bug: Expected TID, opcode %x; ignored\n", | 941 | ipath_dbg("Bug: Expected TID, opcode %x; ignored\n", |
997 | be32_to_cpu(hdr->bth[0]) & 0xff); | 942 | be32_to_cpu(hdr->bth[0]) & 0xff); |
@@ -1024,7 +969,8 @@ reloop: | |||
1024 | */ | 969 | */ |
1025 | if (l == hdrqtail || (i && !(i&0xf))) { | 970 | if (l == hdrqtail || (i && !(i&0xf))) { |
1026 | u64 lval; | 971 | u64 lval; |
1027 | if (l == hdrqtail) /* PE-800 interrupt only on last */ | 972 | if (l == hdrqtail) |
973 | /* request IBA6120 interrupt only on last */ | ||
1028 | lval = dd->ipath_rhdrhead_intr_off | l; | 974 | lval = dd->ipath_rhdrhead_intr_off | l; |
1029 | else | 975 | else |
1030 | lval = l; | 976 | lval = l; |
@@ -1038,7 +984,7 @@ reloop: | |||
1038 | } | 984 | } |
1039 | 985 | ||
1040 | if (!dd->ipath_rhdrhead_intr_off && !reloop) { | 986 | if (!dd->ipath_rhdrhead_intr_off && !reloop) { |
1041 | /* HT-400 workaround; we can have a race clearing chip | 987 | /* IBA6110 workaround; we can have a race clearing chip |
1042 | * interrupt with another interrupt about to be delivered, | 988 | * interrupt with another interrupt about to be delivered, |
1043 | * and can clear it before it is delivered on the GPIO | 989 | * and can clear it before it is delivered on the GPIO |
1044 | * workaround. By doing the extra check here for the | 990 | * workaround. By doing the extra check here for the |
@@ -1211,7 +1157,7 @@ int ipath_setrcvhdrsize(struct ipath_devdata *dd, unsigned rhdrsize) | |||
1211 | * | 1157 | * |
1212 | * do appropriate marking as busy, etc. | 1158 | * do appropriate marking as busy, etc. |
1213 | * returns buffer number if one found (>=0), negative number is error. | 1159 | * returns buffer number if one found (>=0), negative number is error. |
1214 | * Used by ipath_sma_send_pkt and ipath_layer_send | 1160 | * Used by ipath_layer_send |
1215 | */ | 1161 | */ |
1216 | u32 __iomem *ipath_getpiobuf(struct ipath_devdata *dd, u32 * pbufnum) | 1162 | u32 __iomem *ipath_getpiobuf(struct ipath_devdata *dd, u32 * pbufnum) |
1217 | { | 1163 | { |
@@ -1317,13 +1263,6 @@ rescan: | |||
1317 | goto bail; | 1263 | goto bail; |
1318 | } | 1264 | } |
1319 | 1265 | ||
1320 | if (updated) | ||
1321 | /* | ||
1322 | * ran out of bufs, now some (at least this one we just | ||
1323 | * got) are now available, so tell the layered driver. | ||
1324 | */ | ||
1325 | __ipath_layer_intr(dd, IPATH_LAYER_INT_SEND_CONTINUE); | ||
1326 | |||
1327 | /* | 1266 | /* |
1328 | * set next starting place. Since it's just an optimization, | 1267 | * set next starting place. Since it's just an optimization, |
1329 | * it doesn't matter who wins on this, so no locking | 1268 | * it doesn't matter who wins on this, so no locking |
@@ -1500,7 +1439,7 @@ int ipath_waitfor_mdio_cmdready(struct ipath_devdata *dd) | |||
1500 | return ret; | 1439 | return ret; |
1501 | } | 1440 | } |
1502 | 1441 | ||
1503 | void ipath_set_ib_lstate(struct ipath_devdata *dd, int which) | 1442 | static void ipath_set_ib_lstate(struct ipath_devdata *dd, int which) |
1504 | { | 1443 | { |
1505 | static const char *what[4] = { | 1444 | static const char *what[4] = { |
1506 | [0] = "DOWN", | 1445 | [0] = "DOWN", |
@@ -1511,7 +1450,7 @@ void ipath_set_ib_lstate(struct ipath_devdata *dd, int which) | |||
1511 | int linkcmd = (which >> INFINIPATH_IBCC_LINKCMD_SHIFT) & | 1450 | int linkcmd = (which >> INFINIPATH_IBCC_LINKCMD_SHIFT) & |
1512 | INFINIPATH_IBCC_LINKCMD_MASK; | 1451 | INFINIPATH_IBCC_LINKCMD_MASK; |
1513 | 1452 | ||
1514 | ipath_cdbg(SMA, "Trying to move unit %u to %s, current ltstate " | 1453 | ipath_cdbg(VERBOSE, "Trying to move unit %u to %s, current ltstate " |
1515 | "is %s\n", dd->ipath_unit, | 1454 | "is %s\n", dd->ipath_unit, |
1516 | what[linkcmd], | 1455 | what[linkcmd], |
1517 | ipath_ibcstatus_str[ | 1456 | ipath_ibcstatus_str[ |
@@ -1520,7 +1459,7 @@ void ipath_set_ib_lstate(struct ipath_devdata *dd, int which) | |||
1520 | INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) & | 1459 | INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) & |
1521 | INFINIPATH_IBCS_LINKTRAININGSTATE_MASK]); | 1460 | INFINIPATH_IBCS_LINKTRAININGSTATE_MASK]); |
1522 | /* flush all queued sends when going to DOWN or INIT, to be sure that | 1461 | /* flush all queued sends when going to DOWN or INIT, to be sure that |
1523 | * they don't block SMA and other MAD packets */ | 1462 | * they don't block MAD packets */ |
1524 | if (!linkcmd || linkcmd == INFINIPATH_IBCC_LINKCMD_INIT) { | 1463 | if (!linkcmd || linkcmd == INFINIPATH_IBCC_LINKCMD_INIT) { |
1525 | ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, | 1464 | ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, |
1526 | INFINIPATH_S_ABORT); | 1465 | INFINIPATH_S_ABORT); |
@@ -1534,6 +1473,180 @@ void ipath_set_ib_lstate(struct ipath_devdata *dd, int which) | |||
1534 | dd->ipath_ibcctrl | which); | 1473 | dd->ipath_ibcctrl | which); |
1535 | } | 1474 | } |
1536 | 1475 | ||
1476 | int ipath_set_linkstate(struct ipath_devdata *dd, u8 newstate) | ||
1477 | { | ||
1478 | u32 lstate; | ||
1479 | int ret; | ||
1480 | |||
1481 | switch (newstate) { | ||
1482 | case IPATH_IB_LINKDOWN: | ||
1483 | ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKINITCMD_POLL << | ||
1484 | INFINIPATH_IBCC_LINKINITCMD_SHIFT); | ||
1485 | /* don't wait */ | ||
1486 | ret = 0; | ||
1487 | goto bail; | ||
1488 | |||
1489 | case IPATH_IB_LINKDOWN_SLEEP: | ||
1490 | ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKINITCMD_SLEEP << | ||
1491 | INFINIPATH_IBCC_LINKINITCMD_SHIFT); | ||
1492 | /* don't wait */ | ||
1493 | ret = 0; | ||
1494 | goto bail; | ||
1495 | |||
1496 | case IPATH_IB_LINKDOWN_DISABLE: | ||
1497 | ipath_set_ib_lstate(dd, | ||
1498 | INFINIPATH_IBCC_LINKINITCMD_DISABLE << | ||
1499 | INFINIPATH_IBCC_LINKINITCMD_SHIFT); | ||
1500 | /* don't wait */ | ||
1501 | ret = 0; | ||
1502 | goto bail; | ||
1503 | |||
1504 | case IPATH_IB_LINKINIT: | ||
1505 | if (dd->ipath_flags & IPATH_LINKINIT) { | ||
1506 | ret = 0; | ||
1507 | goto bail; | ||
1508 | } | ||
1509 | ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKCMD_INIT << | ||
1510 | INFINIPATH_IBCC_LINKCMD_SHIFT); | ||
1511 | lstate = IPATH_LINKINIT; | ||
1512 | break; | ||
1513 | |||
1514 | case IPATH_IB_LINKARM: | ||
1515 | if (dd->ipath_flags & IPATH_LINKARMED) { | ||
1516 | ret = 0; | ||
1517 | goto bail; | ||
1518 | } | ||
1519 | if (!(dd->ipath_flags & | ||
1520 | (IPATH_LINKINIT | IPATH_LINKACTIVE))) { | ||
1521 | ret = -EINVAL; | ||
1522 | goto bail; | ||
1523 | } | ||
1524 | ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKCMD_ARMED << | ||
1525 | INFINIPATH_IBCC_LINKCMD_SHIFT); | ||
1526 | /* | ||
1527 | * Since the port can transition to ACTIVE by receiving | ||
1528 | * a non VL 15 packet, wait for either state. | ||
1529 | */ | ||
1530 | lstate = IPATH_LINKARMED | IPATH_LINKACTIVE; | ||
1531 | break; | ||
1532 | |||
1533 | case IPATH_IB_LINKACTIVE: | ||
1534 | if (dd->ipath_flags & IPATH_LINKACTIVE) { | ||
1535 | ret = 0; | ||
1536 | goto bail; | ||
1537 | } | ||
1538 | if (!(dd->ipath_flags & IPATH_LINKARMED)) { | ||
1539 | ret = -EINVAL; | ||
1540 | goto bail; | ||
1541 | } | ||
1542 | ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKCMD_ACTIVE << | ||
1543 | INFINIPATH_IBCC_LINKCMD_SHIFT); | ||
1544 | lstate = IPATH_LINKACTIVE; | ||
1545 | break; | ||
1546 | |||
1547 | default: | ||
1548 | ipath_dbg("Invalid linkstate 0x%x requested\n", newstate); | ||
1549 | ret = -EINVAL; | ||
1550 | goto bail; | ||
1551 | } | ||
1552 | ret = ipath_wait_linkstate(dd, lstate, 2000); | ||
1553 | |||
1554 | bail: | ||
1555 | return ret; | ||
1556 | } | ||
1557 | |||
1558 | /** | ||
1559 | * ipath_set_mtu - set the MTU | ||
1560 | * @dd: the infinipath device | ||
1561 | * @arg: the new MTU | ||
1562 | * | ||
1563 | * we can handle "any" incoming size, the issue here is whether we | ||
1564 | * need to restrict our outgoing size. For now, we don't do any | ||
1565 | * sanity checking on this, and we don't deal with what happens to | ||
1566 | * programs that are already running when the size changes. | ||
1567 | * NOTE: changing the MTU will usually cause the IBC to go back to | ||
1568 | * link initialize (IPATH_IBSTATE_INIT) state... | ||
1569 | */ | ||
1570 | int ipath_set_mtu(struct ipath_devdata *dd, u16 arg) | ||
1571 | { | ||
1572 | u32 piosize; | ||
1573 | int changed = 0; | ||
1574 | int ret; | ||
1575 | |||
1576 | /* | ||
1577 | * mtu is IB data payload max. It's the largest power of 2 less | ||
1578 | * than piosize (or even larger, since it only really controls the | ||
1579 | * largest we can receive; we can send the max of the mtu and | ||
1580 | * piosize). We check that it's one of the valid IB sizes. | ||
1581 | */ | ||
1582 | if (arg != 256 && arg != 512 && arg != 1024 && arg != 2048 && | ||
1583 | arg != 4096) { | ||
1584 | ipath_dbg("Trying to set invalid mtu %u, failing\n", arg); | ||
1585 | ret = -EINVAL; | ||
1586 | goto bail; | ||
1587 | } | ||
1588 | if (dd->ipath_ibmtu == arg) { | ||
1589 | ret = 0; /* same as current */ | ||
1590 | goto bail; | ||
1591 | } | ||
1592 | |||
1593 | piosize = dd->ipath_ibmaxlen; | ||
1594 | dd->ipath_ibmtu = arg; | ||
1595 | |||
1596 | if (arg >= (piosize - IPATH_PIO_MAXIBHDR)) { | ||
1597 | /* Only if it's not the initial value (or reset to it) */ | ||
1598 | if (piosize != dd->ipath_init_ibmaxlen) { | ||
1599 | dd->ipath_ibmaxlen = piosize; | ||
1600 | changed = 1; | ||
1601 | } | ||
1602 | } else if ((arg + IPATH_PIO_MAXIBHDR) != dd->ipath_ibmaxlen) { | ||
1603 | piosize = arg + IPATH_PIO_MAXIBHDR; | ||
1604 | ipath_cdbg(VERBOSE, "ibmaxlen was 0x%x, setting to 0x%x " | ||
1605 | "(mtu 0x%x)\n", dd->ipath_ibmaxlen, piosize, | ||
1606 | arg); | ||
1607 | dd->ipath_ibmaxlen = piosize; | ||
1608 | changed = 1; | ||
1609 | } | ||
1610 | |||
1611 | if (changed) { | ||
1612 | /* | ||
1613 | * set the IBC maxpktlength to the size of our pio | ||
1614 | * buffers in words | ||
1615 | */ | ||
1616 | u64 ibc = dd->ipath_ibcctrl; | ||
1617 | ibc &= ~(INFINIPATH_IBCC_MAXPKTLEN_MASK << | ||
1618 | INFINIPATH_IBCC_MAXPKTLEN_SHIFT); | ||
1619 | |||
1620 | piosize = piosize - 2 * sizeof(u32); /* ignore pbc */ | ||
1621 | dd->ipath_ibmaxlen = piosize; | ||
1622 | piosize /= sizeof(u32); /* in words */ | ||
1623 | /* | ||
1624 | * for ICRC, which we only send in diag test pkt mode, and | ||
1625 | * we don't need to worry about that for mtu | ||
1626 | */ | ||
1627 | piosize += 1; | ||
1628 | |||
1629 | ibc |= piosize << INFINIPATH_IBCC_MAXPKTLEN_SHIFT; | ||
1630 | dd->ipath_ibcctrl = ibc; | ||
1631 | ipath_write_kreg(dd, dd->ipath_kregs->kr_ibcctrl, | ||
1632 | dd->ipath_ibcctrl); | ||
1633 | dd->ipath_f_tidtemplate(dd); | ||
1634 | } | ||
1635 | |||
1636 | ret = 0; | ||
1637 | |||
1638 | bail: | ||
1639 | return ret; | ||
1640 | } | ||
1641 | |||
1642 | int ipath_set_lid(struct ipath_devdata *dd, u32 arg, u8 lmc) | ||
1643 | { | ||
1644 | dd->ipath_lid = arg; | ||
1645 | dd->ipath_lmc = lmc; | ||
1646 | |||
1647 | return 0; | ||
1648 | } | ||
1649 | |||
1537 | /** | 1650 | /** |
1538 | * ipath_read_kreg64_port - read a device's per-port 64-bit kernel register | 1651 | * ipath_read_kreg64_port - read a device's per-port 64-bit kernel register |
1539 | * @dd: the infinipath device | 1652 | * @dd: the infinipath device |
@@ -1637,13 +1750,6 @@ void ipath_shutdown_device(struct ipath_devdata *dd) | |||
1637 | ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKINITCMD_DISABLE << | 1750 | ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKINITCMD_DISABLE << |
1638 | INFINIPATH_IBCC_LINKINITCMD_SHIFT); | 1751 | INFINIPATH_IBCC_LINKINITCMD_SHIFT); |
1639 | 1752 | ||
1640 | /* | ||
1641 | * we are shutting down, so tell the layered driver. We don't do | ||
1642 | * this on just a link state change, much like ethernet, a cable | ||
1643 | * unplug, etc. doesn't change driver state | ||
1644 | */ | ||
1645 | ipath_layer_intr(dd, IPATH_LAYER_INT_IF_DOWN); | ||
1646 | |||
1647 | /* disable IBC */ | 1753 | /* disable IBC */ |
1648 | dd->ipath_control &= ~INFINIPATH_C_LINKENABLE; | 1754 | dd->ipath_control &= ~INFINIPATH_C_LINKENABLE; |
1649 | ipath_write_kreg(dd, dd->ipath_kregs->kr_control, | 1755 | ipath_write_kreg(dd, dd->ipath_kregs->kr_control, |
@@ -1743,7 +1849,7 @@ static int __init infinipath_init(void) | |||
1743 | { | 1849 | { |
1744 | int ret; | 1850 | int ret; |
1745 | 1851 | ||
1746 | ipath_dbg(KERN_INFO DRIVER_LOAD_MSG "%s", ipath_core_version); | 1852 | ipath_dbg(KERN_INFO DRIVER_LOAD_MSG "%s", ib_ipath_version); |
1747 | 1853 | ||
1748 | /* | 1854 | /* |
1749 | * These must be called before the driver is registered with | 1855 | * These must be called before the driver is registered with |
@@ -1776,8 +1882,18 @@ static int __init infinipath_init(void) | |||
1776 | goto bail_group; | 1882 | goto bail_group; |
1777 | } | 1883 | } |
1778 | 1884 | ||
1885 | ret = ipath_diagpkt_add(); | ||
1886 | if (ret < 0) { | ||
1887 | printk(KERN_ERR IPATH_DRV_NAME ": Unable to create " | ||
1888 | "diag data device: error %d\n", -ret); | ||
1889 | goto bail_ipathfs; | ||
1890 | } | ||
1891 | |||
1779 | goto bail; | 1892 | goto bail; |
1780 | 1893 | ||
1894 | bail_ipathfs: | ||
1895 | ipath_exit_ipathfs(); | ||
1896 | |||
1781 | bail_group: | 1897 | bail_group: |
1782 | ipath_driver_remove_group(&ipath_driver.driver); | 1898 | ipath_driver_remove_group(&ipath_driver.driver); |
1783 | 1899 | ||
@@ -1888,6 +2004,8 @@ static void __exit infinipath_cleanup(void) | |||
1888 | struct ipath_devdata *dd, *tmp; | 2004 | struct ipath_devdata *dd, *tmp; |
1889 | unsigned long flags; | 2005 | unsigned long flags; |
1890 | 2006 | ||
2007 | ipath_diagpkt_remove(); | ||
2008 | |||
1891 | ipath_exit_ipathfs(); | 2009 | ipath_exit_ipathfs(); |
1892 | 2010 | ||
1893 | ipath_driver_remove_group(&ipath_driver.driver); | 2011 | ipath_driver_remove_group(&ipath_driver.driver); |
@@ -1998,5 +2116,22 @@ bail: | |||
1998 | return ret; | 2116 | return ret; |
1999 | } | 2117 | } |
2000 | 2118 | ||
2119 | int ipath_set_rx_pol_inv(struct ipath_devdata *dd, u8 new_pol_inv) | ||
2120 | { | ||
2121 | u64 val; | ||
2122 | if ( new_pol_inv > INFINIPATH_XGXS_RX_POL_MASK ) { | ||
2123 | return -1; | ||
2124 | } | ||
2125 | if ( dd->ipath_rx_pol_inv != new_pol_inv ) { | ||
2126 | dd->ipath_rx_pol_inv = new_pol_inv; | ||
2127 | val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_xgxsconfig); | ||
2128 | val &= ~(INFINIPATH_XGXS_RX_POL_MASK << | ||
2129 | INFINIPATH_XGXS_RX_POL_SHIFT); | ||
2130 | val |= ((u64)dd->ipath_rx_pol_inv) << | ||
2131 | INFINIPATH_XGXS_RX_POL_SHIFT; | ||
2132 | ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, val); | ||
2133 | } | ||
2134 | return 0; | ||
2135 | } | ||
2001 | module_init(infinipath_init); | 2136 | module_init(infinipath_init); |
2002 | module_exit(infinipath_cleanup); | 2137 | module_exit(infinipath_cleanup); |