Commit 7b34a464 authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

cnic: Fix cnic_cm_abort() error handling.

Fix the code that handles the error case when cnic_cm_abort() cannot
proceed normally.  We cannot just set the csk->state and we must
go through cnic_ready_to_close() to handle all the conditions.  We
also add error return code in cnic_cm_abort().
Signed-off-by: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarEddie Wai <waie@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 943189f1
...@@ -2996,7 +2996,7 @@ static int cnic_cm_connect(struct cnic_sock *csk, struct cnic_sockaddr *saddr) ...@@ -2996,7 +2996,7 @@ static int cnic_cm_connect(struct cnic_sock *csk, struct cnic_sockaddr *saddr)
static int cnic_cm_abort(struct cnic_sock *csk) static int cnic_cm_abort(struct cnic_sock *csk)
{ {
struct cnic_local *cp = csk->dev->cnic_priv; struct cnic_local *cp = csk->dev->cnic_priv;
u32 opcode; u32 opcode = L4_KCQE_OPCODE_VALUE_RESET_COMP;
if (!cnic_in_use(csk)) if (!cnic_in_use(csk))
return -EINVAL; return -EINVAL;
...@@ -3008,12 +3008,9 @@ static int cnic_cm_abort(struct cnic_sock *csk) ...@@ -3008,12 +3008,9 @@ static int cnic_cm_abort(struct cnic_sock *csk)
* connect was not successful. * connect was not successful.
*/ */
csk->state = L4_KCQE_OPCODE_VALUE_RESET_COMP;
if (test_bit(SK_F_PG_OFFLD_COMPLETE, &csk->flags))
opcode = csk->state;
else
opcode = L5CM_RAMROD_CMD_ID_TERMINATE_OFFLOAD;
cp->close_conn(csk, opcode); cp->close_conn(csk, opcode);
if (csk->state != opcode)
return -EALREADY;
return 0; return 0;
} }
...@@ -3206,11 +3203,16 @@ static int cnic_ready_to_close(struct cnic_sock *csk, u32 opcode) ...@@ -3206,11 +3203,16 @@ static int cnic_ready_to_close(struct cnic_sock *csk, u32 opcode)
/* 1. If event opcode matches the expected event in csk->state /* 1. If event opcode matches the expected event in csk->state
* 2. If the expected event is CLOSE_COMP, we accept any event * 2. If the expected event is CLOSE_COMP, we accept any event
* 3. If the expected event is 0, meaning the connection was never
* never established, we accept the opcode from cm_abort.
*/ */
if (opcode == csk->state || if (opcode == csk->state || csk->state == 0 ||
csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP) { csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP) {
if (!test_and_set_bit(SK_F_CLOSING, &csk->flags)) if (!test_and_set_bit(SK_F_CLOSING, &csk->flags)) {
if (csk->state == 0)
csk->state = opcode;
return 1; return 1;
}
} }
return 0; return 0;
} }
...@@ -3227,6 +3229,7 @@ static void cnic_close_bnx2_conn(struct cnic_sock *csk, u32 opcode) ...@@ -3227,6 +3229,7 @@ static void cnic_close_bnx2_conn(struct cnic_sock *csk, u32 opcode)
clear_bit(SK_F_CONNECT_START, &csk->flags); clear_bit(SK_F_CONNECT_START, &csk->flags);
cnic_close_conn(csk); cnic_close_conn(csk);
csk->state = opcode;
cnic_cm_upcall(cp, csk, opcode); cnic_cm_upcall(cp, csk, opcode);
} }
...@@ -3256,8 +3259,12 @@ static void cnic_close_bnx2x_conn(struct cnic_sock *csk, u32 opcode) ...@@ -3256,8 +3259,12 @@ static void cnic_close_bnx2x_conn(struct cnic_sock *csk, u32 opcode)
case L4_KCQE_OPCODE_VALUE_RESET_RECEIVED: case L4_KCQE_OPCODE_VALUE_RESET_RECEIVED:
case L4_KCQE_OPCODE_VALUE_CLOSE_COMP: case L4_KCQE_OPCODE_VALUE_CLOSE_COMP:
case L4_KCQE_OPCODE_VALUE_RESET_COMP: case L4_KCQE_OPCODE_VALUE_RESET_COMP:
if (cnic_ready_to_close(csk, opcode)) if (cnic_ready_to_close(csk, opcode)) {
cmd = L5CM_RAMROD_CMD_ID_SEARCHER_DELETE; if (test_bit(SK_F_PG_OFFLD_COMPLETE, &csk->flags))
cmd = L5CM_RAMROD_CMD_ID_SEARCHER_DELETE;
else
close_complete = 1;
}
break; break;
case L5CM_RAMROD_CMD_ID_SEARCHER_DELETE: case L5CM_RAMROD_CMD_ID_SEARCHER_DELETE:
cmd = L5CM_RAMROD_CMD_ID_TERMINATE_OFFLOAD; cmd = L5CM_RAMROD_CMD_ID_TERMINATE_OFFLOAD;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment