提交 943189f1 编写于 作者: M Michael Chan 提交者: David S. Miller

cnic: Refactor and fix cnic_ready_to_close().

Combine RESET_RECEIVED and RESET_COMP logic and fix race condition
between these 2 events and cnic_cm_close().  In particular, we need
to (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) before we
update csk->state.
Signed-off-by: NMichael Chan <mchan@broadcom.com>
Signed-off-by: NEddie Wai <waie@broadcom.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a1e621bf
...@@ -3198,25 +3198,19 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev) ...@@ -3198,25 +3198,19 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev)
static int cnic_ready_to_close(struct cnic_sock *csk, u32 opcode) static int cnic_ready_to_close(struct cnic_sock *csk, u32 opcode)
{ {
if (opcode == L4_KCQE_OPCODE_VALUE_RESET_RECEIVED) { if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) {
if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) /* Unsolicited RESET_COMP or RESET_RECEIVED */
csk->state = opcode; opcode = L4_KCQE_OPCODE_VALUE_RESET_RECEIVED;
} csk->state = opcode;
if ((opcode == csk->state) ||
(opcode == L4_KCQE_OPCODE_VALUE_RESET_RECEIVED &&
csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP)) {
if (!test_and_set_bit(SK_F_CLOSING, &csk->flags))
return 1;
} }
/* 57710+ only workaround to handle unsolicited RESET_COMP
* which will be treated like a RESET RCVD notification /* 1. If event opcode matches the expected event in csk->state
* which triggers the clean up procedure * 2. If the expected event is CLOSE_COMP, we accept any event
*/ */
else if (opcode == L4_KCQE_OPCODE_VALUE_RESET_COMP) { if (opcode == csk->state ||
if (!test_and_set_bit(SK_F_CLOSING, &csk->flags)) { csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP) {
csk->state = L4_KCQE_OPCODE_VALUE_RESET_RECEIVED; if (!test_and_set_bit(SK_F_CLOSING, &csk->flags))
return 1; return 1;
}
} }
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册