* [PATCH net-next 1/4] cnic: Return error code in cnic_cm_close() if unsuccessful.
@ 2010-06-15 18:57 Michael Chan
2010-06-15 18:57 ` [PATCH net-next 2/4] cnic: Refactor code in cnic_cm_process_kcqe() Michael Chan
2010-06-15 21:24 ` [PATCH net-next 1/4] cnic: Return error code in cnic_cm_close() if unsuccessful David Miller
0 siblings, 2 replies; 8+ messages in thread
From: Michael Chan @ 2010-06-15 18:57 UTC (permalink / raw)
To: davem; +Cc: netdev
So that bnx2i can handle the error condition immediately and not have to
wait for timeout.
Signed-off-by: Michael Chan <mchan@broadcom.com.
Signed-off-by: Eddie Wai <waie@broadcom.com>
---
drivers/net/cnic.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 908d89a..b20e11c 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -3026,6 +3026,8 @@ static int cnic_cm_close(struct cnic_sock *csk)
if (cnic_close_prep(csk)) {
csk->state = L4_KCQE_OPCODE_VALUE_CLOSE_COMP;
return cnic_cm_close_req(csk);
+ } else {
+ return -EALREADY;
}
return 0;
}
--
1.6.4.GIT
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 2/4] cnic: Refactor code in cnic_cm_process_kcqe().
2010-06-15 18:57 [PATCH net-next 1/4] cnic: Return error code in cnic_cm_close() if unsuccessful Michael Chan
@ 2010-06-15 18:57 ` Michael Chan
2010-06-15 18:57 ` [PATCH net-next 3/4] cnic: Refactor and fix cnic_ready_to_close() Michael Chan
2010-06-15 21:24 ` [PATCH net-next 2/4] cnic: Refactor code in cnic_cm_process_kcqe() David Miller
2010-06-15 21:24 ` [PATCH net-next 1/4] cnic: Return error code in cnic_cm_close() if unsuccessful David Miller
1 sibling, 2 replies; 8+ messages in thread
From: Michael Chan @ 2010-06-15 18:57 UTC (permalink / raw)
To: davem; +Cc: netdev
Move chip-specific code to the respective chip's ->close_conn() functions
for better code organization.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Eddie Wai <waie@broadcom.com>
---
drivers/net/cnic.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index b20e11c..48fdbce 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -3143,12 +3143,6 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe)
break;
case L4_KCQE_OPCODE_VALUE_RESET_RECEIVED:
- if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) {
- cnic_cm_upcall(cp, csk, opcode);
- break;
- } else if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags))
- csk->state = opcode;
- /* fall through */
case L4_KCQE_OPCODE_VALUE_CLOSE_COMP:
case L4_KCQE_OPCODE_VALUE_RESET_COMP:
case L5CM_RAMROD_CMD_ID_SEARCHER_DELETE:
@@ -3204,6 +3198,10 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev)
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))
+ csk->state = opcode;
+ }
if ((opcode == csk->state) ||
(opcode == L4_KCQE_OPCODE_VALUE_RESET_RECEIVED &&
csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP)) {
@@ -3228,6 +3226,11 @@ static void cnic_close_bnx2_conn(struct cnic_sock *csk, u32 opcode)
struct cnic_dev *dev = csk->dev;
struct cnic_local *cp = dev->cnic_priv;
+ if (opcode == L4_KCQE_OPCODE_VALUE_RESET_RECEIVED) {
+ cnic_cm_upcall(cp, csk, opcode);
+ return;
+ }
+
clear_bit(SK_F_CONNECT_START, &csk->flags);
cnic_close_conn(csk);
cnic_cm_upcall(cp, csk, opcode);
--
1.6.4.GIT
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 3/4] cnic: Refactor and fix cnic_ready_to_close().
2010-06-15 18:57 ` [PATCH net-next 2/4] cnic: Refactor code in cnic_cm_process_kcqe() Michael Chan
@ 2010-06-15 18:57 ` Michael Chan
2010-06-15 18:57 ` [PATCH net-next 4/4] cnic: Fix cnic_cm_abort() error handling Michael Chan
2010-06-15 21:24 ` [PATCH net-next 3/4] cnic: Refactor and fix cnic_ready_to_close() David Miller
2010-06-15 21:24 ` [PATCH net-next 2/4] cnic: Refactor code in cnic_cm_process_kcqe() David Miller
1 sibling, 2 replies; 8+ messages in thread
From: Michael Chan @ 2010-06-15 18:57 UTC (permalink / raw)
To: davem; +Cc: netdev
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: Michael Chan <mchan@broadcom.com>
Signed-off-by: Eddie Wai <waie@broadcom.com>
---
drivers/net/cnic.c | 26 ++++++++++----------------
1 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 48fdbce..11eeded 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -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)
{
- if (opcode == L4_KCQE_OPCODE_VALUE_RESET_RECEIVED) {
- if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags))
- 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;
+ if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) {
+ /* Unsolicited RESET_COMP or RESET_RECEIVED */
+ opcode = L4_KCQE_OPCODE_VALUE_RESET_RECEIVED;
+ csk->state = opcode;
}
- /* 57710+ only workaround to handle unsolicited RESET_COMP
- * which will be treated like a RESET RCVD notification
- * which triggers the clean up procedure
+
+ /* 1. If event opcode matches the expected event in csk->state
+ * 2. If the expected event is CLOSE_COMP, we accept any event
*/
- else if (opcode == L4_KCQE_OPCODE_VALUE_RESET_COMP) {
- if (!test_and_set_bit(SK_F_CLOSING, &csk->flags)) {
- csk->state = L4_KCQE_OPCODE_VALUE_RESET_RECEIVED;
+ if (opcode == csk->state ||
+ csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP) {
+ if (!test_and_set_bit(SK_F_CLOSING, &csk->flags))
return 1;
- }
}
return 0;
}
--
1.6.4.GIT
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 4/4] cnic: Fix cnic_cm_abort() error handling.
2010-06-15 18:57 ` [PATCH net-next 3/4] cnic: Refactor and fix cnic_ready_to_close() Michael Chan
@ 2010-06-15 18:57 ` Michael Chan
2010-06-15 21:24 ` David Miller
2010-06-15 21:24 ` [PATCH net-next 3/4] cnic: Refactor and fix cnic_ready_to_close() David Miller
1 sibling, 1 reply; 8+ messages in thread
From: Michael Chan @ 2010-06-15 18:57 UTC (permalink / raw)
To: davem; +Cc: netdev
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: Michael Chan <mchan@broadcom.com>
Signed-off-by: Eddie Wai <waie@broadcom.com>
---
drivers/net/cnic.c | 29 ++++++++++++++++++-----------
1 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 11eeded..e5539f0 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -2996,7 +2996,7 @@ err_out:
static int cnic_cm_abort(struct cnic_sock *csk)
{
struct cnic_local *cp = csk->dev->cnic_priv;
- u32 opcode;
+ u32 opcode = L4_KCQE_OPCODE_VALUE_RESET_COMP;
if (!cnic_in_use(csk))
return -EINVAL;
@@ -3008,12 +3008,9 @@ static int cnic_cm_abort(struct cnic_sock *csk)
* 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);
+ if (csk->state != opcode)
+ return -EALREADY;
return 0;
}
@@ -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
* 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 ||
- csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP) {
- if (!test_and_set_bit(SK_F_CLOSING, &csk->flags))
+ if (opcode == csk->state || csk->state == 0 ||
+ csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP) {
+ if (!test_and_set_bit(SK_F_CLOSING, &csk->flags)) {
+ if (csk->state == 0)
+ csk->state = opcode;
return 1;
+ }
}
return 0;
}
@@ -3227,6 +3229,7 @@ static void cnic_close_bnx2_conn(struct cnic_sock *csk, u32 opcode)
clear_bit(SK_F_CONNECT_START, &csk->flags);
cnic_close_conn(csk);
+ csk->state = opcode;
cnic_cm_upcall(cp, csk, 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_CLOSE_COMP:
case L4_KCQE_OPCODE_VALUE_RESET_COMP:
- if (cnic_ready_to_close(csk, opcode))
- cmd = L5CM_RAMROD_CMD_ID_SEARCHER_DELETE;
+ if (cnic_ready_to_close(csk, opcode)) {
+ if (test_bit(SK_F_PG_OFFLD_COMPLETE, &csk->flags))
+ cmd = L5CM_RAMROD_CMD_ID_SEARCHER_DELETE;
+ else
+ close_complete = 1;
+ }
break;
case L5CM_RAMROD_CMD_ID_SEARCHER_DELETE:
cmd = L5CM_RAMROD_CMD_ID_TERMINATE_OFFLOAD;
--
1.6.4.GIT
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 1/4] cnic: Return error code in cnic_cm_close() if unsuccessful.
2010-06-15 18:57 [PATCH net-next 1/4] cnic: Return error code in cnic_cm_close() if unsuccessful Michael Chan
2010-06-15 18:57 ` [PATCH net-next 2/4] cnic: Refactor code in cnic_cm_process_kcqe() Michael Chan
@ 2010-06-15 21:24 ` David Miller
1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2010-06-15 21:24 UTC (permalink / raw)
To: mchan; +Cc: netdev
From: "Michael Chan" <mchan@broadcom.com>
Date: Tue, 15 Jun 2010 11:57:00 -0700
> So that bnx2i can handle the error condition immediately and not have to
> wait for timeout.
>
> Signed-off-by: Michael Chan <mchan@broadcom.com.
> Signed-off-by: Eddie Wai <waie@broadcom.com>
Applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 2/4] cnic: Refactor code in cnic_cm_process_kcqe().
2010-06-15 18:57 ` [PATCH net-next 2/4] cnic: Refactor code in cnic_cm_process_kcqe() Michael Chan
2010-06-15 18:57 ` [PATCH net-next 3/4] cnic: Refactor and fix cnic_ready_to_close() Michael Chan
@ 2010-06-15 21:24 ` David Miller
1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2010-06-15 21:24 UTC (permalink / raw)
To: mchan; +Cc: netdev
From: "Michael Chan" <mchan@broadcom.com>
Date: Tue, 15 Jun 2010 11:57:01 -0700
> Move chip-specific code to the respective chip's ->close_conn() functions
> for better code organization.
>
> Signed-off-by: Michael Chan <mchan@broadcom.com>
> Signed-off-by: Eddie Wai <waie@broadcom.com>
Applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 3/4] cnic: Refactor and fix cnic_ready_to_close().
2010-06-15 18:57 ` [PATCH net-next 3/4] cnic: Refactor and fix cnic_ready_to_close() Michael Chan
2010-06-15 18:57 ` [PATCH net-next 4/4] cnic: Fix cnic_cm_abort() error handling Michael Chan
@ 2010-06-15 21:24 ` David Miller
1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2010-06-15 21:24 UTC (permalink / raw)
To: mchan; +Cc: netdev
From: "Michael Chan" <mchan@broadcom.com>
Date: Tue, 15 Jun 2010 11:57:02 -0700
> 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: Michael Chan <mchan@broadcom.com>
> Signed-off-by: Eddie Wai <waie@broadcom.com>
Applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 4/4] cnic: Fix cnic_cm_abort() error handling.
2010-06-15 18:57 ` [PATCH net-next 4/4] cnic: Fix cnic_cm_abort() error handling Michael Chan
@ 2010-06-15 21:24 ` David Miller
0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2010-06-15 21:24 UTC (permalink / raw)
To: mchan; +Cc: netdev
From: "Michael Chan" <mchan@broadcom.com>
Date: Tue, 15 Jun 2010 11:57:03 -0700
> 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: Michael Chan <mchan@broadcom.com>
> Signed-off-by: Eddie Wai <waie@broadcom.com>
Applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-06-15 21:24 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-15 18:57 [PATCH net-next 1/4] cnic: Return error code in cnic_cm_close() if unsuccessful Michael Chan
2010-06-15 18:57 ` [PATCH net-next 2/4] cnic: Refactor code in cnic_cm_process_kcqe() Michael Chan
2010-06-15 18:57 ` [PATCH net-next 3/4] cnic: Refactor and fix cnic_ready_to_close() Michael Chan
2010-06-15 18:57 ` [PATCH net-next 4/4] cnic: Fix cnic_cm_abort() error handling Michael Chan
2010-06-15 21:24 ` David Miller
2010-06-15 21:24 ` [PATCH net-next 3/4] cnic: Refactor and fix cnic_ready_to_close() David Miller
2010-06-15 21:24 ` [PATCH net-next 2/4] cnic: Refactor code in cnic_cm_process_kcqe() David Miller
2010-06-15 21:24 ` [PATCH net-next 1/4] cnic: Return error code in cnic_cm_close() if unsuccessful David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).