static void update_statusp(struct hfi1_pportdata *ppd, u32 state);
static int wait_logical_linkstate(struct hfi1_pportdata *ppd, u32 state,
int msecs);
+static void log_state_transition(struct hfi1_pportdata *ppd, u32 state);
+static void log_physical_state(struct hfi1_pportdata *ppd, u32 state);
static int wait_physical_linkstate(struct hfi1_pportdata *ppd, u32 state,
int msecs);
static void read_planned_down_reason_code(struct hfi1_devdata *dd, u8 *pdrrc);
}
/*
- * driver_physical_state - convert the driver's notion of a port's
+ * driver_pstate - convert the driver's notion of a port's
* state (an HLS_*) into a physical state (a {IB,OPA}_PORTPHYSSTATE_*).
* Return -1 (converted to a u32) to indicate error.
*/
-u32 driver_physical_state(struct hfi1_pportdata *ppd)
+u32 driver_pstate(struct hfi1_pportdata *ppd)
{
switch (ppd->host_link_state) {
case HLS_UP_INIT:
if (ret)
goto_offline(ppd, 0);
else
- cache_physical_state(ppd);
+ log_physical_state(ppd, PLS_POLLING);
break;
case HLS_DN_DISABLE:
/* link is disabled */
if (ppd->host_link_state != HLS_DN_POLL)
goto unexpected;
ppd->host_link_state = HLS_VERIFY_CAP;
- cache_physical_state(ppd);
+ log_physical_state(ppd, PLS_CONFIGPHY_VERIFYCAP);
break;
case HLS_GOING_UP:
if (ppd->host_link_state != HLS_VERIFY_CAP)
return 0;
}
+static void log_state_transition(struct hfi1_pportdata *ppd, u32 state)
+{
+ u32 ib_pstate = chip_to_opa_pstate(ppd->dd, state);
+
+ dd_dev_info(ppd->dd,
+ "physical state changed to %s (0x%x), phy 0x%x\n",
+ opa_pstate_name(ib_pstate), ib_pstate, state);
+}
+
/*
- * Read the physical hardware link state and set the driver's cached value
- * of it.
+ * Read the physical hardware link state and check if it matches host
+ * drivers anticipated state.
*/
-void cache_physical_state(struct hfi1_pportdata *ppd)
+static void log_physical_state(struct hfi1_pportdata *ppd, u32 state)
{
- u32 read_pstate;
- u32 ib_pstate;
+ u32 read_state = read_physical_state(ppd->dd);
- read_pstate = read_physical_state(ppd->dd);
- ib_pstate = chip_to_opa_pstate(ppd->dd, read_pstate);
- /* check if OPA pstate changed */
- if (chip_to_opa_pstate(ppd->dd, ppd->pstate) != ib_pstate) {
- dd_dev_info(ppd->dd,
- "%s: physical state changed to %s (0x%x), phy 0x%x\n",
- __func__, opa_pstate_name(ib_pstate), ib_pstate,
- read_pstate);
+ if (read_state == state) {
+ log_state_transition(ppd, state);
+ } else {
+ dd_dev_err(ppd->dd,
+ "anticipated phy link state 0x%x, read 0x%x\n",
+ state, read_state);
}
- ppd->pstate = read_pstate;
}
/*
static int wait_physical_linkstate(struct hfi1_pportdata *ppd, u32 state,
int msecs)
{
+ u32 read_state;
unsigned long timeout;
timeout = jiffies + msecs_to_jiffies(msecs);
while (1) {
- cache_physical_state(ppd);
- if (ppd->pstate == state)
+ read_state = read_physical_state(ppd->dd);
+ if (read_state == state)
break;
if (time_after(jiffies, timeout)) {
dd_dev_err(ppd->dd,
- "timeout waiting for phy link state 0x%x, current state is 0x%x\n",
- state, ppd->pstate);
+ "timeout waiting for phy link state 0x%x\n",
+ state);
return -ETIMEDOUT;
}
usleep_range(1950, 2050); /* sleep 2ms-ish */
}
+ log_state_transition(ppd, state);
return 0;
}
/* start in offline */
ppd->host_link_state = HLS_DN_OFFLINE;
init_vl_arb_caches(ppd);
- ppd->pstate = PLS_OFFLINE;
}
dd->link_default = HLS_DN_POLL;
u8 link_enabled; /* link enabled? */
u8 linkinit_reason;
u8 local_tx_rate; /* rate given to 8051 firmware */
- u8 pstate; /* info only */
u8 qsfp_retry_count;
/* placeholders for IB MAD packet settings */
int hfi1_reset_device(int);
-/* return the driver's idea of the physical OPA port state */
-static inline u32 driver_pstate(struct hfi1_pportdata *ppd)
-{
- /*
- * When DC is shut down and state is changed, its CSRs are not
- * impacted, therefore host_link_state should be used to get
- * current physical state.
- */
- if (ppd->dd->dc_shutdown)
- return driver_physical_state(ppd);
- /*
- * The driver does some processing from the time the physical
- * link state is at LINKUP to the time the SM can be notified
- * as such. Return IB_PORTPHYSSTATE_TRAINING until the software
- * state is ready.
- */
- if (ppd->pstate == PLS_LINKUP &&
- !(ppd->host_link_state & HLS_UP))
- return IB_PORTPHYSSTATE_TRAINING;
- else
- return chip_to_opa_pstate(ppd->dd, ppd->pstate);
-}
-
void receive_interrupt_work(struct work_struct *work);
/* extract service channel from header and rhf */