aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/ipath/ipath_kernel.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_kernel.h')
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h304
1 files changed, 263 insertions, 41 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index ecf3f7ff7717..5863cbe99303 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -1,7 +1,7 @@
1#ifndef _IPATH_KERNEL_H 1#ifndef _IPATH_KERNEL_H
2#define _IPATH_KERNEL_H 2#define _IPATH_KERNEL_H
3/* 3/*
4 * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 4 * Copyright (c) 2006, 2007, 2008 QLogic Corporation. All rights reserved.
5 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 5 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
6 * 6 *
7 * This software is available to you under a choice of one of two 7 * This software is available to you under a choice of one of two
@@ -42,6 +42,8 @@
42#include <linux/pci.h> 42#include <linux/pci.h>
43#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
44#include <linux/mutex.h> 44#include <linux/mutex.h>
45#include <linux/list.h>
46#include <linux/scatterlist.h>
45#include <asm/io.h> 47#include <asm/io.h>
46#include <rdma/ib_verbs.h> 48#include <rdma/ib_verbs.h>
47 49
@@ -175,9 +177,13 @@ struct ipath_portdata {
175 u16 poll_type; 177 u16 poll_type;
176 /* port rcvhdrq head offset */ 178 /* port rcvhdrq head offset */
177 u32 port_head; 179 u32 port_head;
180 /* receive packet sequence counter */
181 u32 port_seq_cnt;
178}; 182};
179 183
180struct sk_buff; 184struct sk_buff;
185struct ipath_sge_state;
186struct ipath_verbs_txreq;
181 187
182/* 188/*
183 * control information for layered drivers 189 * control information for layered drivers
@@ -191,6 +197,40 @@ struct ipath_skbinfo {
191 dma_addr_t phys; 197 dma_addr_t phys;
192}; 198};
193 199
200struct ipath_sdma_txreq {
201 int flags;
202 int sg_count;
203 union {
204 struct scatterlist *sg;
205 void *map_addr;
206 };
207 void (*callback)(void *, int);
208 void *callback_cookie;
209 int callback_status;
210 u16 start_idx; /* sdma private */
211 u16 next_descq_idx; /* sdma private */
212 struct list_head list; /* sdma private */
213};
214
215struct ipath_sdma_desc {
216 __le64 qw[2];
217};
218
219#define IPATH_SDMA_TXREQ_F_USELARGEBUF 0x1
220#define IPATH_SDMA_TXREQ_F_HEADTOHOST 0x2
221#define IPATH_SDMA_TXREQ_F_INTREQ 0x4
222#define IPATH_SDMA_TXREQ_F_FREEBUF 0x8
223#define IPATH_SDMA_TXREQ_F_FREEDESC 0x10
224#define IPATH_SDMA_TXREQ_F_VL15 0x20
225
226#define IPATH_SDMA_TXREQ_S_OK 0
227#define IPATH_SDMA_TXREQ_S_SENDERROR 1
228#define IPATH_SDMA_TXREQ_S_ABORTED 2
229#define IPATH_SDMA_TXREQ_S_SHUTDOWN 3
230
231/* max dwords in small buffer packet */
232#define IPATH_SMALLBUF_DWORDS (dd->ipath_piosize2k >> 2)
233
194/* 234/*
195 * Possible IB config parameters for ipath_f_get/set_ib_cfg() 235 * Possible IB config parameters for ipath_f_get/set_ib_cfg()
196 */ 236 */
@@ -221,11 +261,6 @@ struct ipath_devdata {
221 unsigned long ipath_physaddr; 261 unsigned long ipath_physaddr;
222 /* base of memory alloced for ipath_kregbase, for free */ 262 /* base of memory alloced for ipath_kregbase, for free */
223 u64 *ipath_kregalloc; 263 u64 *ipath_kregalloc;
224 /*
225 * virtual address where port0 rcvhdrqtail updated for this unit.
226 * only written to by the chip, not the driver.
227 */
228 volatile __le64 *ipath_hdrqtailptr;
229 /* ipath_cfgports pointers */ 264 /* ipath_cfgports pointers */
230 struct ipath_portdata **ipath_pd; 265 struct ipath_portdata **ipath_pd;
231 /* sk_buffs used by port 0 eager receive queue */ 266 /* sk_buffs used by port 0 eager receive queue */
@@ -283,6 +318,7 @@ struct ipath_devdata {
283 /* per chip actions needed for IB Link up/down changes */ 318 /* per chip actions needed for IB Link up/down changes */
284 int (*ipath_f_ib_updown)(struct ipath_devdata *, int, u64); 319 int (*ipath_f_ib_updown)(struct ipath_devdata *, int, u64);
285 320
321 unsigned ipath_lastegr_idx;
286 struct ipath_ibdev *verbs_dev; 322 struct ipath_ibdev *verbs_dev;
287 struct timer_list verbs_timer; 323 struct timer_list verbs_timer;
288 /* total dwords sent (summed from counter) */ 324 /* total dwords sent (summed from counter) */
@@ -309,6 +345,7 @@ struct ipath_devdata {
309 ipath_err_t ipath_lasthwerror; 345 ipath_err_t ipath_lasthwerror;
310 /* errors masked because they occur too fast */ 346 /* errors masked because they occur too fast */
311 ipath_err_t ipath_maskederrs; 347 ipath_err_t ipath_maskederrs;
348 u64 ipath_lastlinkrecov; /* link recoveries at last ACTIVE */
312 /* time in jiffies at which to re-enable maskederrs */ 349 /* time in jiffies at which to re-enable maskederrs */
313 unsigned long ipath_unmasktime; 350 unsigned long ipath_unmasktime;
314 /* count of egrfull errors, combined for all ports */ 351 /* count of egrfull errors, combined for all ports */
@@ -347,6 +384,7 @@ struct ipath_devdata {
347 u32 ipath_lastrpkts; 384 u32 ipath_lastrpkts;
348 /* pio bufs allocated per port */ 385 /* pio bufs allocated per port */
349 u32 ipath_pbufsport; 386 u32 ipath_pbufsport;
387 u32 ipath_pioupd_thresh; /* update threshold, some chips */
350 /* 388 /*
351 * number of ports configured as max; zero is set to number chip 389 * number of ports configured as max; zero is set to number chip
352 * supports, less gives more pio bufs/port, etc. 390 * supports, less gives more pio bufs/port, etc.
@@ -365,6 +403,7 @@ struct ipath_devdata {
365 * get to multiple devices 403 * get to multiple devices
366 */ 404 */
367 u32 ipath_lastpioindex; 405 u32 ipath_lastpioindex;
406 u32 ipath_lastpioindexl;
368 /* max length of freezemsg */ 407 /* max length of freezemsg */
369 u32 ipath_freezelen; 408 u32 ipath_freezelen;
370 /* 409 /*
@@ -381,6 +420,15 @@ struct ipath_devdata {
381 u32 ipath_pcibar0; 420 u32 ipath_pcibar0;
382 /* so we can rewrite it after a chip reset */ 421 /* so we can rewrite it after a chip reset */
383 u32 ipath_pcibar1; 422 u32 ipath_pcibar1;
423 u32 ipath_x1_fix_tries;
424 u32 ipath_autoneg_tries;
425 u32 serdes_first_init_done;
426
427 struct ipath_relock {
428 atomic_t ipath_relock_timer_active;
429 struct timer_list ipath_relock_timer;
430 unsigned int ipath_relock_interval; /* in jiffies */
431 } ipath_relock_singleton;
384 432
385 /* interrupt number */ 433 /* interrupt number */
386 int ipath_irq; 434 int ipath_irq;
@@ -403,7 +451,7 @@ struct ipath_devdata {
403 u64 __iomem *ipath_egrtidbase; 451 u64 __iomem *ipath_egrtidbase;
404 /* lock to workaround chip bug 9437 and others */ 452 /* lock to workaround chip bug 9437 and others */
405 spinlock_t ipath_kernel_tid_lock; 453 spinlock_t ipath_kernel_tid_lock;
406 spinlock_t ipath_tid_lock; 454 spinlock_t ipath_user_tid_lock;
407 spinlock_t ipath_sendctrl_lock; 455 spinlock_t ipath_sendctrl_lock;
408 456
409 /* 457 /*
@@ -422,11 +470,48 @@ struct ipath_devdata {
422 struct class_device *diag_class_dev; 470 struct class_device *diag_class_dev;
423 /* timer used to prevent stats overflow, error throttling, etc. */ 471 /* timer used to prevent stats overflow, error throttling, etc. */
424 struct timer_list ipath_stats_timer; 472 struct timer_list ipath_stats_timer;
473 /* timer to verify interrupts work, and fallback if possible */
474 struct timer_list ipath_intrchk_timer;
425 void *ipath_dummy_hdrq; /* used after port close */ 475 void *ipath_dummy_hdrq; /* used after port close */
426 dma_addr_t ipath_dummy_hdrq_phys; 476 dma_addr_t ipath_dummy_hdrq_phys;
427 477
478 /* SendDMA related entries */
479 spinlock_t ipath_sdma_lock;
480 u64 ipath_sdma_status;
481 unsigned long ipath_sdma_abort_jiffies;
482 unsigned long ipath_sdma_abort_intr_timeout;
483 unsigned long ipath_sdma_buf_jiffies;
484 struct ipath_sdma_desc *ipath_sdma_descq;
485 u64 ipath_sdma_descq_added;
486 u64 ipath_sdma_descq_removed;
487 int ipath_sdma_desc_nreserved;
488 u16 ipath_sdma_descq_cnt;
489 u16 ipath_sdma_descq_tail;
490 u16 ipath_sdma_descq_head;
491 u16 ipath_sdma_next_intr;
492 u16 ipath_sdma_reset_wait;
493 u8 ipath_sdma_generation;
494 struct tasklet_struct ipath_sdma_abort_task;
495 struct tasklet_struct ipath_sdma_notify_task;
496 struct list_head ipath_sdma_activelist;
497 struct list_head ipath_sdma_notifylist;
498 atomic_t ipath_sdma_vl15_count;
499 struct timer_list ipath_sdma_vl15_timer;
500
501 dma_addr_t ipath_sdma_descq_phys;
502 volatile __le64 *ipath_sdma_head_dma;
503 dma_addr_t ipath_sdma_head_phys;
504
428 unsigned long ipath_ureg_align; /* user register alignment */ 505 unsigned long ipath_ureg_align; /* user register alignment */
429 506
507 struct delayed_work ipath_autoneg_work;
508 wait_queue_head_t ipath_autoneg_wait;
509
510 /* HoL blocking / user app forward-progress state */
511 unsigned ipath_hol_state;
512 unsigned ipath_hol_next;
513 struct timer_list ipath_hol_timer;
514
430 /* 515 /*
431 * Shadow copies of registers; size indicates read access size. 516 * Shadow copies of registers; size indicates read access size.
432 * Most of them are readonly, but some are write-only register, 517 * Most of them are readonly, but some are write-only register,
@@ -447,6 +532,8 @@ struct ipath_devdata {
447 * init time. 532 * init time.
448 */ 533 */
449 unsigned long ipath_pioavailshadow[8]; 534 unsigned long ipath_pioavailshadow[8];
535 /* bitmap of send buffers available for the kernel to use with PIO. */
536 unsigned long ipath_pioavailkernel[8];
450 /* shadow of kr_gpio_out, for rmw ops */ 537 /* shadow of kr_gpio_out, for rmw ops */
451 u64 ipath_gpio_out; 538 u64 ipath_gpio_out;
452 /* shadow the gpio mask register */ 539 /* shadow the gpio mask register */
@@ -472,6 +559,8 @@ struct ipath_devdata {
472 u64 ipath_intconfig; 559 u64 ipath_intconfig;
473 /* kr_sendpiobufbase value */ 560 /* kr_sendpiobufbase value */
474 u64 ipath_piobufbase; 561 u64 ipath_piobufbase;
562 /* kr_ibcddrctrl shadow */
563 u64 ipath_ibcddrctrl;
475 564
476 /* these are the "32 bit" regs */ 565 /* these are the "32 bit" regs */
477 566
@@ -488,7 +577,10 @@ struct ipath_devdata {
488 unsigned long ipath_rcvctrl; 577 unsigned long ipath_rcvctrl;
489 /* shadow kr_sendctrl */ 578 /* shadow kr_sendctrl */
490 unsigned long ipath_sendctrl; 579 unsigned long ipath_sendctrl;
491 unsigned long ipath_lastcancel; /* to not count armlaunch after cancel */ 580 /* to not count armlaunch after cancel */
581 unsigned long ipath_lastcancel;
582 /* count cases where special trigger was needed (double write) */
583 unsigned long ipath_spectriggerhit;
492 584
493 /* value we put in kr_rcvhdrcnt */ 585 /* value we put in kr_rcvhdrcnt */
494 u32 ipath_rcvhdrcnt; 586 u32 ipath_rcvhdrcnt;
@@ -510,6 +602,7 @@ struct ipath_devdata {
510 u32 ipath_piobcnt4k; 602 u32 ipath_piobcnt4k;
511 /* size in bytes of "4KB" PIO buffers */ 603 /* size in bytes of "4KB" PIO buffers */
512 u32 ipath_piosize4k; 604 u32 ipath_piosize4k;
605 u32 ipath_pioreserved; /* reserved special-inkernel; */
513 /* kr_rcvegrbase value */ 606 /* kr_rcvegrbase value */
514 u32 ipath_rcvegrbase; 607 u32 ipath_rcvegrbase;
515 /* kr_rcvegrcnt value */ 608 /* kr_rcvegrcnt value */
@@ -546,10 +639,10 @@ struct ipath_devdata {
546 u32 ipath_init_ibmaxlen; 639 u32 ipath_init_ibmaxlen;
547 /* size of each rcvegrbuffer */ 640 /* size of each rcvegrbuffer */
548 u32 ipath_rcvegrbufsize; 641 u32 ipath_rcvegrbufsize;
549 /* width (2,4,8,16,32) from HT config reg */ 642 /* localbus width (1, 2,4,8,16,32) from config space */
550 u32 ipath_htwidth; 643 u32 ipath_lbus_width;
551 /* HT speed (200,400,800,1000) from HT config */ 644 /* localbus speed (HT: 200,400,800,1000; PCIe 2500) */
552 u32 ipath_htspeed; 645 u32 ipath_lbus_speed;
553 /* 646 /*
554 * number of sequential ibcstatus change for polling active/quiet 647 * number of sequential ibcstatus change for polling active/quiet
555 * (i.e., link not coming up). 648 * (i.e., link not coming up).
@@ -573,21 +666,14 @@ struct ipath_devdata {
573 */ 666 */
574 u8 ipath_serial[16]; 667 u8 ipath_serial[16];
575 /* human readable board version */ 668 /* human readable board version */
576 u8 ipath_boardversion[80]; 669 u8 ipath_boardversion[96];
670 u8 ipath_lbus_info[32]; /* human readable localbus info */
577 /* chip major rev, from ipath_revision */ 671 /* chip major rev, from ipath_revision */
578 u8 ipath_majrev; 672 u8 ipath_majrev;
579 /* chip minor rev, from ipath_revision */ 673 /* chip minor rev, from ipath_revision */
580 u8 ipath_minrev; 674 u8 ipath_minrev;
581 /* board rev, from ipath_revision */ 675 /* board rev, from ipath_revision */
582 u8 ipath_boardrev; 676 u8 ipath_boardrev;
583
584 u8 ipath_r_portenable_shift;
585 u8 ipath_r_intravail_shift;
586 u8 ipath_r_tailupd_shift;
587 u8 ipath_r_portcfg_shift;
588
589 /* unit # of this chip, if present */
590 int ipath_unit;
591 /* saved for restore after reset */ 677 /* saved for restore after reset */
592 u8 ipath_pci_cacheline; 678 u8 ipath_pci_cacheline;
593 /* LID mask control */ 679 /* LID mask control */
@@ -603,6 +689,14 @@ struct ipath_devdata {
603 /* Rx Polarity inversion (compensate for ~tx on partner) */ 689 /* Rx Polarity inversion (compensate for ~tx on partner) */
604 u8 ipath_rx_pol_inv; 690 u8 ipath_rx_pol_inv;
605 691
692 u8 ipath_r_portenable_shift;
693 u8 ipath_r_intravail_shift;
694 u8 ipath_r_tailupd_shift;
695 u8 ipath_r_portcfg_shift;
696
697 /* unit # of this chip, if present */
698 int ipath_unit;
699
606 /* local link integrity counter */ 700 /* local link integrity counter */
607 u32 ipath_lli_counter; 701 u32 ipath_lli_counter;
608 /* local link integrity errors */ 702 /* local link integrity errors */
@@ -617,9 +711,6 @@ struct ipath_devdata {
617 u32 ipath_overrun_thresh_errs; 711 u32 ipath_overrun_thresh_errs;
618 u32 ipath_lli_errs; 712 u32 ipath_lli_errs;
619 713
620 /* status check work */
621 struct delayed_work status_work;
622
623 /* 714 /*
624 * Not all devices managed by a driver instance are the same 715 * Not all devices managed by a driver instance are the same
625 * type, so these fields must be per-device. 716 * type, so these fields must be per-device.
@@ -632,8 +723,8 @@ struct ipath_devdata {
632 * Below should be computable from number of ports, 723 * Below should be computable from number of ports,
633 * since they are never modified. 724 * since they are never modified.
634 */ 725 */
635 u32 ipath_i_rcvavail_mask; 726 u64 ipath_i_rcvavail_mask;
636 u32 ipath_i_rcvurg_mask; 727 u64 ipath_i_rcvurg_mask;
637 u16 ipath_i_rcvurg_shift; 728 u16 ipath_i_rcvurg_shift;
638 u16 ipath_i_rcvavail_shift; 729 u16 ipath_i_rcvavail_shift;
639 730
@@ -641,8 +732,9 @@ struct ipath_devdata {
641 * Register bits for selecting i2c direction and values, used for 732 * Register bits for selecting i2c direction and values, used for
642 * I2C serial flash. 733 * I2C serial flash.
643 */ 734 */
644 u16 ipath_gpio_sda_num; 735 u8 ipath_gpio_sda_num;
645 u16 ipath_gpio_scl_num; 736 u8 ipath_gpio_scl_num;
737 u8 ipath_i2c_chain_type;
646 u64 ipath_gpio_sda; 738 u64 ipath_gpio_sda;
647 u64 ipath_gpio_scl; 739 u64 ipath_gpio_scl;
648 740
@@ -703,13 +795,51 @@ struct ipath_devdata {
703 /* interrupt mitigation reload register info */ 795 /* interrupt mitigation reload register info */
704 u16 ipath_jint_idle_ticks; /* idle clock ticks */ 796 u16 ipath_jint_idle_ticks; /* idle clock ticks */
705 u16 ipath_jint_max_packets; /* max packets across all ports */ 797 u16 ipath_jint_max_packets; /* max packets across all ports */
798
799 /*
800 * lock for access to SerDes, and flags to sequence preset
801 * versus steady-state. 7220-only at the moment.
802 */
803 spinlock_t ipath_sdepb_lock;
804 u8 ipath_presets_needed; /* Set if presets to be restored next DOWN */
706}; 805};
707 806
807/* ipath_hol_state values (stopping/starting user proc, send flushing) */
808#define IPATH_HOL_UP 0
809#define IPATH_HOL_DOWN 1
810/* ipath_hol_next toggle values, used when hol_state IPATH_HOL_DOWN */
811#define IPATH_HOL_DOWNSTOP 0
812#define IPATH_HOL_DOWNCONT 1
813
814/* bit positions for sdma_status */
815#define IPATH_SDMA_ABORTING 0
816#define IPATH_SDMA_DISARMED 1
817#define IPATH_SDMA_DISABLED 2
818#define IPATH_SDMA_LAYERBUF 3
819#define IPATH_SDMA_RUNNING 62
820#define IPATH_SDMA_SHUTDOWN 63
821
822/* bit combinations that correspond to abort states */
823#define IPATH_SDMA_ABORT_NONE 0
824#define IPATH_SDMA_ABORT_ABORTING (1UL << IPATH_SDMA_ABORTING)
825#define IPATH_SDMA_ABORT_DISARMED ((1UL << IPATH_SDMA_ABORTING) | \
826 (1UL << IPATH_SDMA_DISARMED))
827#define IPATH_SDMA_ABORT_DISABLED ((1UL << IPATH_SDMA_ABORTING) | \
828 (1UL << IPATH_SDMA_DISABLED))
829#define IPATH_SDMA_ABORT_ABORTED ((1UL << IPATH_SDMA_ABORTING) | \
830 (1UL << IPATH_SDMA_DISARMED) | (1UL << IPATH_SDMA_DISABLED))
831#define IPATH_SDMA_ABORT_MASK ((1UL<<IPATH_SDMA_ABORTING) | \
832 (1UL << IPATH_SDMA_DISARMED) | (1UL << IPATH_SDMA_DISABLED))
833
834#define IPATH_SDMA_BUF_NONE 0
835#define IPATH_SDMA_BUF_MASK (1UL<<IPATH_SDMA_LAYERBUF)
836
708/* Private data for file operations */ 837/* Private data for file operations */
709struct ipath_filedata { 838struct ipath_filedata {
710 struct ipath_portdata *pd; 839 struct ipath_portdata *pd;
711 unsigned subport; 840 unsigned subport;
712 unsigned tidcursor; 841 unsigned tidcursor;
842 struct ipath_user_sdma_queue *pq;
713}; 843};
714extern struct list_head ipath_dev_list; 844extern struct list_head ipath_dev_list;
715extern spinlock_t ipath_devs_lock; 845extern spinlock_t ipath_devs_lock;
@@ -718,7 +848,7 @@ extern struct ipath_devdata *ipath_lookup(int unit);
718int ipath_init_chip(struct ipath_devdata *, int); 848int ipath_init_chip(struct ipath_devdata *, int);
719int ipath_enable_wc(struct ipath_devdata *dd); 849int ipath_enable_wc(struct ipath_devdata *dd);
720void ipath_disable_wc(struct ipath_devdata *dd); 850void ipath_disable_wc(struct ipath_devdata *dd);
721int ipath_count_units(int *npresentp, int *nupp, u32 *maxportsp); 851int ipath_count_units(int *npresentp, int *nupp, int *maxportsp);
722void ipath_shutdown_device(struct ipath_devdata *); 852void ipath_shutdown_device(struct ipath_devdata *);
723void ipath_clear_freeze(struct ipath_devdata *); 853void ipath_clear_freeze(struct ipath_devdata *);
724 854
@@ -741,7 +871,8 @@ struct sk_buff *ipath_alloc_skb(struct ipath_devdata *dd, gfp_t);
741extern int ipath_diag_inuse; 871extern int ipath_diag_inuse;
742 872
743irqreturn_t ipath_intr(int irq, void *devid); 873irqreturn_t ipath_intr(int irq, void *devid);
744int ipath_decode_err(char *buf, size_t blen, ipath_err_t err); 874int ipath_decode_err(struct ipath_devdata *dd, char *buf, size_t blen,
875 ipath_err_t err);
745#if __IPATH_INFO || __IPATH_DBG 876#if __IPATH_INFO || __IPATH_DBG
746extern const char *ipath_ibcstatus_str[]; 877extern const char *ipath_ibcstatus_str[];
747#endif 878#endif
@@ -774,6 +905,13 @@ int ipath_set_lid(struct ipath_devdata *, u32, u8);
774int ipath_set_rx_pol_inv(struct ipath_devdata *dd, u8 new_pol_inv); 905int ipath_set_rx_pol_inv(struct ipath_devdata *dd, u8 new_pol_inv);
775void ipath_enable_armlaunch(struct ipath_devdata *); 906void ipath_enable_armlaunch(struct ipath_devdata *);
776void ipath_disable_armlaunch(struct ipath_devdata *); 907void ipath_disable_armlaunch(struct ipath_devdata *);
908void ipath_hol_down(struct ipath_devdata *);
909void ipath_hol_up(struct ipath_devdata *);
910void ipath_hol_event(unsigned long);
911void ipath_toggle_rclkrls(struct ipath_devdata *);
912void ipath_sd7220_clr_ibpar(struct ipath_devdata *);
913void ipath_set_relock_poll(struct ipath_devdata *, int);
914void ipath_shutdown_relock_poll(struct ipath_devdata *);
777 915
778/* for use in system calls, where we want to know device type, etc. */ 916/* for use in system calls, where we want to know device type, etc. */
779#define port_fp(fp) ((struct ipath_filedata *)(fp)->private_data)->pd 917#define port_fp(fp) ((struct ipath_filedata *)(fp)->private_data)->pd
@@ -781,11 +919,15 @@ void ipath_disable_armlaunch(struct ipath_devdata *);
781 ((struct ipath_filedata *)(fp)->private_data)->subport 919 ((struct ipath_filedata *)(fp)->private_data)->subport
782#define tidcursor_fp(fp) \ 920#define tidcursor_fp(fp) \
783 ((struct ipath_filedata *)(fp)->private_data)->tidcursor 921 ((struct ipath_filedata *)(fp)->private_data)->tidcursor
922#define user_sdma_queue_fp(fp) \
923 ((struct ipath_filedata *)(fp)->private_data)->pq
784 924
785/* 925/*
786 * values for ipath_flags 926 * values for ipath_flags
787 */ 927 */
788/* The chip is up and initted */ 928 /* chip can report link latency (IB 1.2) */
929#define IPATH_HAS_LINK_LATENCY 0x1
930 /* The chip is up and initted */
789#define IPATH_INITTED 0x2 931#define IPATH_INITTED 0x2
790 /* set if any user code has set kr_rcvhdrsize */ 932 /* set if any user code has set kr_rcvhdrsize */
791#define IPATH_RCVHDRSZ_SET 0x4 933#define IPATH_RCVHDRSZ_SET 0x4
@@ -809,6 +951,8 @@ void ipath_disable_armlaunch(struct ipath_devdata *);
809#define IPATH_LINKUNK 0x400 951#define IPATH_LINKUNK 0x400
810 /* Write combining flush needed for PIO */ 952 /* Write combining flush needed for PIO */
811#define IPATH_PIO_FLUSH_WC 0x1000 953#define IPATH_PIO_FLUSH_WC 0x1000
954 /* DMA Receive tail pointer */
955#define IPATH_NODMA_RTAIL 0x2000
812 /* no IB cable, or no device on IB cable */ 956 /* no IB cable, or no device on IB cable */
813#define IPATH_NOCABLE 0x4000 957#define IPATH_NOCABLE 0x4000
814 /* Supports port zero per packet receive interrupts via 958 /* Supports port zero per packet receive interrupts via
@@ -819,16 +963,26 @@ void ipath_disable_armlaunch(struct ipath_devdata *);
819 /* packet/word counters are 32 bit, else those 4 counters 963 /* packet/word counters are 32 bit, else those 4 counters
820 * are 64bit */ 964 * are 64bit */
821#define IPATH_32BITCOUNTERS 0x20000 965#define IPATH_32BITCOUNTERS 0x20000
822 /* can miss port0 rx interrupts */
823 /* Interrupt register is 64 bits */ 966 /* Interrupt register is 64 bits */
824#define IPATH_INTREG_64 0x40000 967#define IPATH_INTREG_64 0x40000
968 /* can miss port0 rx interrupts */
825#define IPATH_DISABLED 0x80000 /* administratively disabled */ 969#define IPATH_DISABLED 0x80000 /* administratively disabled */
826 /* Use GPIO interrupts for new counters */ 970 /* Use GPIO interrupts for new counters */
827#define IPATH_GPIO_ERRINTRS 0x100000 971#define IPATH_GPIO_ERRINTRS 0x100000
828#define IPATH_SWAP_PIOBUFS 0x200000 972#define IPATH_SWAP_PIOBUFS 0x200000
973 /* Supports Send DMA */
974#define IPATH_HAS_SEND_DMA 0x400000
975 /* Supports Send Count (not just word count) in PBC */
976#define IPATH_HAS_PBC_CNT 0x800000
829 /* Suppress heartbeat, even if turning off loopback */ 977 /* Suppress heartbeat, even if turning off loopback */
830#define IPATH_NO_HRTBT 0x1000000 978#define IPATH_NO_HRTBT 0x1000000
979#define IPATH_HAS_THRESH_UPDATE 0x4000000
831#define IPATH_HAS_MULT_IB_SPEED 0x8000000 980#define IPATH_HAS_MULT_IB_SPEED 0x8000000
981#define IPATH_IB_AUTONEG_INPROG 0x10000000
982#define IPATH_IB_AUTONEG_FAILED 0x20000000
983 /* Linkdown-disable intentionally, Do not attempt to bring up */
984#define IPATH_IB_LINK_DISABLED 0x40000000
985#define IPATH_IB_FORCE_NOTIFY 0x80000000 /* force notify on next ib change */
832 986
833/* Bits in GPIO for the added interrupts */ 987/* Bits in GPIO for the added interrupts */
834#define IPATH_GPIO_PORT0_BIT 2 988#define IPATH_GPIO_PORT0_BIT 2
@@ -847,13 +1001,18 @@ void ipath_disable_armlaunch(struct ipath_devdata *);
847 1001
848/* free up any allocated data at closes */ 1002/* free up any allocated data at closes */
849void ipath_free_data(struct ipath_portdata *dd); 1003void ipath_free_data(struct ipath_portdata *dd);
850u32 __iomem *ipath_getpiobuf(struct ipath_devdata *, u32 *); 1004u32 __iomem *ipath_getpiobuf(struct ipath_devdata *, u32, u32 *);
1005void ipath_chg_pioavailkernel(struct ipath_devdata *dd, unsigned start,
1006 unsigned len, int avail);
1007void ipath_init_iba7220_funcs(struct ipath_devdata *);
851void ipath_init_iba6120_funcs(struct ipath_devdata *); 1008void ipath_init_iba6120_funcs(struct ipath_devdata *);
852void ipath_init_iba6110_funcs(struct ipath_devdata *); 1009void ipath_init_iba6110_funcs(struct ipath_devdata *);
853void ipath_get_eeprom_info(struct ipath_devdata *); 1010void ipath_get_eeprom_info(struct ipath_devdata *);
854int ipath_update_eeprom_log(struct ipath_devdata *dd); 1011int ipath_update_eeprom_log(struct ipath_devdata *dd);
855void ipath_inc_eeprom_err(struct ipath_devdata *dd, u32 eidx, u32 incr); 1012void ipath_inc_eeprom_err(struct ipath_devdata *dd, u32 eidx, u32 incr);
856u64 ipath_snap_cntr(struct ipath_devdata *, ipath_creg); 1013u64 ipath_snap_cntr(struct ipath_devdata *, ipath_creg);
1014void ipath_disarm_senderrbufs(struct ipath_devdata *, int);
1015void ipath_force_pio_avail_update(struct ipath_devdata *);
857void signal_ib_event(struct ipath_devdata *dd, enum ib_event_type ev); 1016void signal_ib_event(struct ipath_devdata *dd, enum ib_event_type ev);
858 1017
859/* 1018/*
@@ -865,6 +1024,34 @@ void signal_ib_event(struct ipath_devdata *dd, enum ib_event_type ev);
865#define IPATH_LED_LOG 2 /* Logical (link) YELLOW LED */ 1024#define IPATH_LED_LOG 2 /* Logical (link) YELLOW LED */
866void ipath_set_led_override(struct ipath_devdata *dd, unsigned int val); 1025void ipath_set_led_override(struct ipath_devdata *dd, unsigned int val);
867 1026
1027/* send dma routines */
1028int setup_sdma(struct ipath_devdata *);
1029void teardown_sdma(struct ipath_devdata *);
1030void ipath_restart_sdma(struct ipath_devdata *);
1031void ipath_sdma_intr(struct ipath_devdata *);
1032int ipath_sdma_verbs_send(struct ipath_devdata *, struct ipath_sge_state *,
1033 u32, struct ipath_verbs_txreq *);
1034/* ipath_sdma_lock should be locked before calling this. */
1035int ipath_sdma_make_progress(struct ipath_devdata *dd);
1036
1037/* must be called under ipath_sdma_lock */
1038static inline u16 ipath_sdma_descq_freecnt(const struct ipath_devdata *dd)
1039{
1040 return dd->ipath_sdma_descq_cnt -
1041 (dd->ipath_sdma_descq_added - dd->ipath_sdma_descq_removed) -
1042 1 - dd->ipath_sdma_desc_nreserved;
1043}
1044
1045static inline void ipath_sdma_desc_reserve(struct ipath_devdata *dd, u16 cnt)
1046{
1047 dd->ipath_sdma_desc_nreserved += cnt;
1048}
1049
1050static inline void ipath_sdma_desc_unreserve(struct ipath_devdata *dd, u16 cnt)
1051{
1052 dd->ipath_sdma_desc_nreserved -= cnt;
1053}
1054
868/* 1055/*
869 * number of words used for protocol header if not set by ipath_userinit(); 1056 * number of words used for protocol header if not set by ipath_userinit();
870 */ 1057 */
@@ -875,6 +1062,8 @@ void ipath_release_user_pages(struct page **, size_t);
875void ipath_release_user_pages_on_close(struct page **, size_t); 1062void ipath_release_user_pages_on_close(struct page **, size_t);
876int ipath_eeprom_read(struct ipath_devdata *, u8, void *, int); 1063int ipath_eeprom_read(struct ipath_devdata *, u8, void *, int);
877int ipath_eeprom_write(struct ipath_devdata *, u8, const void *, int); 1064int ipath_eeprom_write(struct ipath_devdata *, u8, const void *, int);
1065int ipath_tempsense_read(struct ipath_devdata *, u8 regnum);
1066int ipath_tempsense_write(struct ipath_devdata *, u8 regnum, u8 data);
878 1067
879/* these are used for the registers that vary with port */ 1068/* these are used for the registers that vary with port */
880void ipath_write_kreg_port(const struct ipath_devdata *, ipath_kreg, 1069void ipath_write_kreg_port(const struct ipath_devdata *, ipath_kreg,
@@ -891,8 +1080,7 @@ void ipath_write_kreg_port(const struct ipath_devdata *, ipath_kreg,
891 1080
892/* 1081/*
893 * At the moment, none of the s-registers are writable, so no 1082 * At the moment, none of the s-registers are writable, so no
894 * ipath_write_sreg(), and none of the c-registers are writable, so no 1083 * ipath_write_sreg().
895 * ipath_write_creg().
896 */ 1084 */
897 1085
898/** 1086/**
@@ -1001,6 +1189,27 @@ static inline u32 ipath_get_rcvhdrtail(const struct ipath_portdata *pd)
1001 pd->port_rcvhdrtail_kvaddr)); 1189 pd->port_rcvhdrtail_kvaddr));
1002} 1190}
1003 1191
1192static inline u32 ipath_get_hdrqtail(const struct ipath_portdata *pd)
1193{
1194 const struct ipath_devdata *dd = pd->port_dd;
1195 u32 hdrqtail;
1196
1197 if (dd->ipath_flags & IPATH_NODMA_RTAIL) {
1198 __le32 *rhf_addr;
1199 u32 seq;
1200
1201 rhf_addr = (__le32 *) pd->port_rcvhdrq +
1202 pd->port_head + dd->ipath_rhf_offset;
1203 seq = ipath_hdrget_seq(rhf_addr);
1204 hdrqtail = pd->port_head;
1205 if (seq == pd->port_seq_cnt)
1206 hdrqtail++;
1207 } else
1208 hdrqtail = ipath_get_rcvhdrtail(pd);
1209
1210 return hdrqtail;
1211}
1212
1004static inline u64 ipath_read_ireg(const struct ipath_devdata *dd, ipath_kreg r) 1213static inline u64 ipath_read_ireg(const struct ipath_devdata *dd, ipath_kreg r)
1005{ 1214{
1006 return (dd->ipath_flags & IPATH_INTREG_64) ? 1215 return (dd->ipath_flags & IPATH_INTREG_64) ?
@@ -1029,6 +1238,21 @@ static inline u32 ipath_ib_linktrstate(struct ipath_devdata *dd, u64 ibcs)
1029} 1238}
1030 1239
1031/* 1240/*
1241 * from contents of IBCStatus (or a saved copy), return logical link state
1242 * combination of link state and linktraining state (down, active, init,
1243 * arm, etc.
1244 */
1245static inline u32 ipath_ib_state(struct ipath_devdata *dd, u64 ibcs)
1246{
1247 u32 ibs;
1248 ibs = (u32)(ibcs >> INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) &
1249 dd->ibcs_lts_mask;
1250 ibs |= (u32)(ibcs &
1251 (INFINIPATH_IBCS_LINKSTATE_MASK << dd->ibcs_ls_shift));
1252 return ibs;
1253}
1254
1255/*
1032 * sysfs interface. 1256 * sysfs interface.
1033 */ 1257 */
1034 1258
@@ -1053,6 +1277,7 @@ int ipathfs_remove_device(struct ipath_devdata *);
1053dma_addr_t ipath_map_page(struct pci_dev *, struct page *, unsigned long, 1277dma_addr_t ipath_map_page(struct pci_dev *, struct page *, unsigned long,
1054 size_t, int); 1278 size_t, int);
1055dma_addr_t ipath_map_single(struct pci_dev *, void *, size_t, int); 1279dma_addr_t ipath_map_single(struct pci_dev *, void *, size_t, int);
1280const char *ipath_get_unit_name(int unit);
1056 1281
1057/* 1282/*
1058 * Flush write combining store buffers (if present) and perform a write 1283 * Flush write combining store buffers (if present) and perform a write
@@ -1065,11 +1290,8 @@ dma_addr_t ipath_map_single(struct pci_dev *, void *, size_t, int);
1065#endif 1290#endif
1066 1291
1067extern unsigned ipath_debug; /* debugging bit mask */ 1292extern unsigned ipath_debug; /* debugging bit mask */
1068 1293extern unsigned ipath_linkrecovery;
1069#define IPATH_MAX_PARITY_ATTEMPTS 10000 /* max times to try recovery */ 1294extern unsigned ipath_mtu4096;
1070
1071const char *ipath_get_unit_name(int unit);
1072
1073extern struct mutex ipath_mutex; 1295extern struct mutex ipath_mutex;
1074 1296
1075#define IPATH_DRV_NAME "ib_ipath" 1297#define IPATH_DRV_NAME "ib_ipath"
@@ -1096,7 +1318,7 @@ extern struct mutex ipath_mutex;
1096 1318
1097# define __IPATH_DBG_WHICH(which,fmt,...) \ 1319# define __IPATH_DBG_WHICH(which,fmt,...) \
1098 do { \ 1320 do { \
1099 if(unlikely(ipath_debug&(which))) \ 1321 if (unlikely(ipath_debug & (which))) \
1100 printk(KERN_DEBUG IPATH_DRV_NAME ": %s: " fmt, \ 1322 printk(KERN_DEBUG IPATH_DRV_NAME ": %s: " fmt, \
1101 __func__,##__VA_ARGS__); \ 1323 __func__,##__VA_ARGS__); \
1102 } while(0) 1324 } while(0)