1 From 5192fa99f0d267eb7bd1c79e556430ea8911ae38 Mon Sep 17 00:00:00 2001
2 From: Jan Kiszka <jan.kiszka@siemens.com>
3 Date: Sun, 4 Mar 2018 13:50:24 +0100
4 Subject: [PATCH] ivshmem-net: Refactor and comment ivshm_net_state_change
6 This should make the state transitioning logic clearer. Also avoid the
7 harmless but redundant netif_carrier_on/ivshm_net_run in RUN state.
9 Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
10 (cherry picked from commit 8539efe70fbdf4a0bea75a97c1628fbb38b6590b)
12 drivers/net/ivshmem-net.c | 23 ++++++++++++++++++++---
13 1 file changed, 20 insertions(+), 3 deletions(-)
15 --- a/drivers/net/ivshmem-net.c
16 +++ b/drivers/net/ivshmem-net.c
17 @@ -575,14 +575,21 @@ static void ivshm_net_state_change(struc
18 struct net_device *ndev = in->napi.dev;
19 u32 rstate = readl(&in->ivshm_regs->rstate);
23 case IVSHM_NET_STATE_RESET:
25 + * Wait for the remote to leave READY/RUN before transitioning
28 if (rstate < IVSHM_NET_STATE_READY)
29 ivshm_net_set_state(in, IVSHM_NET_STATE_INIT);
32 case IVSHM_NET_STATE_INIT:
34 + * Wait for the remote to leave RESET before performing the
35 + * initialization and moving to READY.
37 if (rstate > IVSHM_NET_STATE_RESET) {
38 ivshm_net_init_queues(ndev);
39 ivshm_net_set_state(in, IVSHM_NET_STATE_READY);
40 @@ -594,11 +601,21 @@ static void ivshm_net_state_change(struc
43 case IVSHM_NET_STATE_READY:
44 - case IVSHM_NET_STATE_RUN:
46 + * Link is up and we are running once the remote is in READY or
49 if (rstate >= IVSHM_NET_STATE_READY) {
50 netif_carrier_on(ndev);
52 - } else if (rstate == IVSHM_NET_STATE_RESET) {
56 + case IVSHM_NET_STATE_RUN:
58 + * If the remote goes to RESET, we need to follow immediately.
60 + if (rstate == IVSHM_NET_STATE_RESET) {
61 netif_carrier_off(ndev);
62 ivshm_net_do_stop(ndev);