提交 2928db4c 编写于 作者: A Andre Detsch 提交者: David S. Miller

ehea: Fix synchronization between HW and SW send queue

ehea: Fix synchronization between HW and SW send queue

When memory is added to / removed from a partition via the Memory DLPAR
mechanism, the eHEA driver has to do a couple of things to reflect the
memory change in its own IO address translation tables. This involves
stopping and restarting the HW queues.
During this operation, it is possible that HW and SW pointer into these
queues get out of sync. This results in a situation where packets that
are attached to a send queue are not transmitted immediately, but
delayed until further X packets have been put on the queue.

This patch detects such loss of synchronization, and resets the ehea
port when needed.
Signed-off-by: NJan-Bernd Themann <themann@de.ibm.com>
Signed-off-by: NAndre Detsch <adetsch@br.ibm.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 96ac4f6b
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <asm/io.h> #include <asm/io.h>
#define DRV_NAME "ehea" #define DRV_NAME "ehea"
#define DRV_VERSION "EHEA_0105" #define DRV_VERSION "EHEA_0106"
/* eHEA capability flags */ /* eHEA capability flags */
#define DLPAR_PORT_ADD_REM 1 #define DLPAR_PORT_ADD_REM 1
...@@ -400,6 +400,7 @@ struct ehea_port_res { ...@@ -400,6 +400,7 @@ struct ehea_port_res {
u32 poll_counter; u32 poll_counter;
struct net_lro_mgr lro_mgr; struct net_lro_mgr lro_mgr;
struct net_lro_desc lro_desc[MAX_LRO_DESCRIPTORS]; struct net_lro_desc lro_desc[MAX_LRO_DESCRIPTORS];
int sq_restart_flag;
}; };
......
...@@ -776,6 +776,53 @@ static int ehea_proc_rwqes(struct net_device *dev, ...@@ -776,6 +776,53 @@ static int ehea_proc_rwqes(struct net_device *dev,
return processed; return processed;
} }
#define SWQE_RESTART_CHECK 0xdeadbeaff00d0000ull
static void reset_sq_restart_flag(struct ehea_port *port)
{
int i;
for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) {
struct ehea_port_res *pr = &port->port_res[i];
pr->sq_restart_flag = 0;
}
}
static void check_sqs(struct ehea_port *port)
{
struct ehea_swqe *swqe;
int swqe_index;
int i, k;
for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) {
struct ehea_port_res *pr = &port->port_res[i];
k = 0;
swqe = ehea_get_swqe(pr->qp, &swqe_index);
memset(swqe, 0, SWQE_HEADER_SIZE);
atomic_dec(&pr->swqe_avail);
swqe->tx_control |= EHEA_SWQE_PURGE;
swqe->wr_id = SWQE_RESTART_CHECK;
swqe->tx_control |= EHEA_SWQE_SIGNALLED_COMPLETION;
swqe->tx_control |= EHEA_SWQE_IMM_DATA_PRESENT;
swqe->immediate_data_length = 80;
ehea_post_swqe(pr->qp, swqe);
while (pr->sq_restart_flag == 0) {
msleep(5);
if (++k == 100) {
ehea_error("HW/SW queues out of sync");
ehea_schedule_port_reset(pr->port);
return;
}
}
}
return;
}
static struct ehea_cqe *ehea_proc_cqes(struct ehea_port_res *pr, int my_quota) static struct ehea_cqe *ehea_proc_cqes(struct ehea_port_res *pr, int my_quota)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -793,6 +840,13 @@ static struct ehea_cqe *ehea_proc_cqes(struct ehea_port_res *pr, int my_quota) ...@@ -793,6 +840,13 @@ static struct ehea_cqe *ehea_proc_cqes(struct ehea_port_res *pr, int my_quota)
cqe_counter++; cqe_counter++;
rmb(); rmb();
if (cqe->wr_id == SWQE_RESTART_CHECK) {
pr->sq_restart_flag = 1;
swqe_av++;
break;
}
if (cqe->status & EHEA_CQE_STAT_ERR_MASK) { if (cqe->status & EHEA_CQE_STAT_ERR_MASK) {
ehea_error("Bad send completion status=0x%04X", ehea_error("Bad send completion status=0x%04X",
cqe->status); cqe->status);
...@@ -2675,10 +2729,12 @@ static void ehea_flush_sq(struct ehea_port *port) ...@@ -2675,10 +2729,12 @@ static void ehea_flush_sq(struct ehea_port *port)
int k = 0; int k = 0;
while (atomic_read(&pr->swqe_avail) < swqe_max) { while (atomic_read(&pr->swqe_avail) < swqe_max) {
msleep(5); msleep(5);
if (++k == 20) if (++k == 20) {
ehea_error("WARNING: sq not flushed completely");
break; break;
} }
} }
}
} }
int ehea_stop_qps(struct net_device *dev) int ehea_stop_qps(struct net_device *dev)
...@@ -2917,6 +2973,7 @@ static void ehea_rereg_mrs(struct work_struct *work) ...@@ -2917,6 +2973,7 @@ static void ehea_rereg_mrs(struct work_struct *work)
port_napi_disable(port); port_napi_disable(port);
mutex_unlock(&port->port_lock); mutex_unlock(&port->port_lock);
} }
reset_sq_restart_flag(port);
} }
/* Unregister old memory region */ /* Unregister old memory region */
...@@ -2951,6 +3008,7 @@ static void ehea_rereg_mrs(struct work_struct *work) ...@@ -2951,6 +3008,7 @@ static void ehea_rereg_mrs(struct work_struct *work)
mutex_lock(&port->port_lock); mutex_lock(&port->port_lock);
port_napi_enable(port); port_napi_enable(port);
ret = ehea_restart_qps(dev); ret = ehea_restart_qps(dev);
check_sqs(port);
if (!ret) if (!ret)
netif_wake_queue(dev); netif_wake_queue(dev);
mutex_unlock(&port->port_lock); mutex_unlock(&port->port_lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册