aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bna/bna_ctrl.c
diff options
context:
space:
mode:
authorRasesh Mody <rmody@brocade.com>2010-12-23 16:45:02 -0500
committerDavid S. Miller <davem@davemloft.net>2010-12-25 22:15:59 -0500
commit0613ecfc94b13e86c9ff1252fd63e35a94475cd6 (patch)
treedec37b55b50fbb3583c909530cbdbe985834093b /drivers/net/bna/bna_ctrl.c
parentbe7fa3263a15d3f278c3bfbf606ec169aaa3a920 (diff)
bna: Port enable disable sync and txq priority fix
Change Details: - Fixed port enable/disable sync through a change in LL port state machine - Change txq->priority masking to 0x7 (3 bits) from 0x3 (2 bits) Signed-off-by: Debashis Dutt <ddutt@brocade.com> Signed-off-by: Rasesh Mody <rmody@brocade.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bna/bna_ctrl.c')
-rw-r--r--drivers/net/bna/bna_ctrl.c136
1 files changed, 106 insertions, 30 deletions
diff --git a/drivers/net/bna/bna_ctrl.c b/drivers/net/bna/bna_ctrl.c
index 07b26598546e..68e4c5eced53 100644
--- a/drivers/net/bna/bna_ctrl.c
+++ b/drivers/net/bna/bna_ctrl.c
@@ -59,14 +59,70 @@ bna_port_cb_link_down(struct bna_port *port, int status)
59 port->link_cbfn(port->bna->bnad, BNA_LINK_DOWN); 59 port->link_cbfn(port->bna->bnad, BNA_LINK_DOWN);
60} 60}
61 61
62static inline int
63llport_can_be_up(struct bna_llport *llport)
64{
65 int ready = 0;
66 if (llport->type == BNA_PORT_T_REGULAR)
67 ready = ((llport->flags & BNA_LLPORT_F_ADMIN_UP) &&
68 (llport->flags & BNA_LLPORT_F_RX_STARTED) &&
69 (llport->flags & BNA_LLPORT_F_PORT_ENABLED));
70 else
71 ready = ((llport->flags & BNA_LLPORT_F_ADMIN_UP) &&
72 (llport->flags & BNA_LLPORT_F_RX_STARTED) &&
73 !(llport->flags & BNA_LLPORT_F_PORT_ENABLED));
74 return ready;
75}
76
77#define llport_is_up llport_can_be_up
78
79enum bna_llport_event {
80 LLPORT_E_START = 1,
81 LLPORT_E_STOP = 2,
82 LLPORT_E_FAIL = 3,
83 LLPORT_E_UP = 4,
84 LLPORT_E_DOWN = 5,
85 LLPORT_E_FWRESP_UP_OK = 6,
86 LLPORT_E_FWRESP_UP_FAIL = 7,
87 LLPORT_E_FWRESP_DOWN = 8
88};
89
90static void
91bna_llport_cb_port_enabled(struct bna_llport *llport)
92{
93 llport->flags |= BNA_LLPORT_F_PORT_ENABLED;
94
95 if (llport_can_be_up(llport))
96 bfa_fsm_send_event(llport, LLPORT_E_UP);
97}
98
99static void
100bna_llport_cb_port_disabled(struct bna_llport *llport)
101{
102 int llport_up = llport_is_up(llport);
103
104 llport->flags &= ~BNA_LLPORT_F_PORT_ENABLED;
105
106 if (llport_up)
107 bfa_fsm_send_event(llport, LLPORT_E_DOWN);
108}
109
62/** 110/**
63 * MBOX 111 * MBOX
64 */ 112 */
65static int 113static int
66bna_is_aen(u8 msg_id) 114bna_is_aen(u8 msg_id)
67{ 115{
68 return msg_id == BFI_LL_I2H_LINK_DOWN_AEN || 116 switch (msg_id) {
69 msg_id == BFI_LL_I2H_LINK_UP_AEN; 117 case BFI_LL_I2H_LINK_DOWN_AEN:
118 case BFI_LL_I2H_LINK_UP_AEN:
119 case BFI_LL_I2H_PORT_ENABLE_AEN:
120 case BFI_LL_I2H_PORT_DISABLE_AEN:
121 return 1;
122
123 default:
124 return 0;
125 }
70} 126}
71 127
72static void 128static void
@@ -81,6 +137,12 @@ bna_mbox_aen_callback(struct bna *bna, struct bfi_mbmsg *msg)
81 case BFI_LL_I2H_LINK_DOWN_AEN: 137 case BFI_LL_I2H_LINK_DOWN_AEN:
82 bna_port_cb_link_down(&bna->port, aen->reason); 138 bna_port_cb_link_down(&bna->port, aen->reason);
83 break; 139 break;
140 case BFI_LL_I2H_PORT_ENABLE_AEN:
141 bna_llport_cb_port_enabled(&bna->port.llport);
142 break;
143 case BFI_LL_I2H_PORT_DISABLE_AEN:
144 bna_llport_cb_port_disabled(&bna->port.llport);
145 break;
84 default: 146 default:
85 break; 147 break;
86 } 148 }
@@ -251,16 +313,6 @@ static void bna_llport_start(struct bna_llport *llport);
251static void bna_llport_stop(struct bna_llport *llport); 313static void bna_llport_stop(struct bna_llport *llport);
252static void bna_llport_fail(struct bna_llport *llport); 314static void bna_llport_fail(struct bna_llport *llport);
253 315
254enum bna_llport_event {
255 LLPORT_E_START = 1,
256 LLPORT_E_STOP = 2,
257 LLPORT_E_FAIL = 3,
258 LLPORT_E_UP = 4,
259 LLPORT_E_DOWN = 5,
260 LLPORT_E_FWRESP_UP = 6,
261 LLPORT_E_FWRESP_DOWN = 7
262};
263
264enum bna_llport_state { 316enum bna_llport_state {
265 BNA_LLPORT_STOPPED = 1, 317 BNA_LLPORT_STOPPED = 1,
266 BNA_LLPORT_DOWN = 2, 318 BNA_LLPORT_DOWN = 2,
@@ -320,7 +372,7 @@ bna_llport_sm_stopped(struct bna_llport *llport,
320 /* No-op */ 372 /* No-op */
321 break; 373 break;
322 374
323 case LLPORT_E_FWRESP_UP: 375 case LLPORT_E_FWRESP_UP_OK:
324 case LLPORT_E_FWRESP_DOWN: 376 case LLPORT_E_FWRESP_DOWN:
325 /** 377 /**
326 * These events are received due to flushing of mbox when 378 * These events are received due to flushing of mbox when
@@ -366,6 +418,7 @@ bna_llport_sm_down(struct bna_llport *llport,
366static void 418static void
367bna_llport_sm_up_resp_wait_entry(struct bna_llport *llport) 419bna_llport_sm_up_resp_wait_entry(struct bna_llport *llport)
368{ 420{
421 BUG_ON(!llport_can_be_up(llport));
369 /** 422 /**
370 * NOTE: Do not call bna_fw_llport_up() here. That will over step 423 * NOTE: Do not call bna_fw_llport_up() here. That will over step
371 * mbox due to down_resp_wait -> up_resp_wait transition on event 424 * mbox due to down_resp_wait -> up_resp_wait transition on event
@@ -390,10 +443,14 @@ bna_llport_sm_up_resp_wait(struct bna_llport *llport,
390 bfa_fsm_set_state(llport, bna_llport_sm_down_resp_wait); 443 bfa_fsm_set_state(llport, bna_llport_sm_down_resp_wait);
391 break; 444 break;
392 445
393 case LLPORT_E_FWRESP_UP: 446 case LLPORT_E_FWRESP_UP_OK:
394 bfa_fsm_set_state(llport, bna_llport_sm_up); 447 bfa_fsm_set_state(llport, bna_llport_sm_up);
395 break; 448 break;
396 449
450 case LLPORT_E_FWRESP_UP_FAIL:
451 bfa_fsm_set_state(llport, bna_llport_sm_down);
452 break;
453
397 case LLPORT_E_FWRESP_DOWN: 454 case LLPORT_E_FWRESP_DOWN:
398 /* down_resp_wait -> up_resp_wait transition on LLPORT_E_UP */ 455 /* down_resp_wait -> up_resp_wait transition on LLPORT_E_UP */
399 bna_fw_llport_up(llport); 456 bna_fw_llport_up(llport);
@@ -431,11 +488,12 @@ bna_llport_sm_down_resp_wait(struct bna_llport *llport,
431 bfa_fsm_set_state(llport, bna_llport_sm_up_resp_wait); 488 bfa_fsm_set_state(llport, bna_llport_sm_up_resp_wait);
432 break; 489 break;
433 490
434 case LLPORT_E_FWRESP_UP: 491 case LLPORT_E_FWRESP_UP_OK:
435 /* up_resp_wait->down_resp_wait transition on LLPORT_E_DOWN */ 492 /* up_resp_wait->down_resp_wait transition on LLPORT_E_DOWN */
436 bna_fw_llport_down(llport); 493 bna_fw_llport_down(llport);
437 break; 494 break;
438 495
496 case LLPORT_E_FWRESP_UP_FAIL:
439 case LLPORT_E_FWRESP_DOWN: 497 case LLPORT_E_FWRESP_DOWN:
440 bfa_fsm_set_state(llport, bna_llport_sm_down); 498 bfa_fsm_set_state(llport, bna_llport_sm_down);
441 break; 499 break;
@@ -496,11 +554,12 @@ bna_llport_sm_last_resp_wait(struct bna_llport *llport,
496 /* No-op */ 554 /* No-op */
497 break; 555 break;
498 556
499 case LLPORT_E_FWRESP_UP: 557 case LLPORT_E_FWRESP_UP_OK:
500 /* up_resp_wait->last_resp_wait transition on LLPORT_T_STOP */ 558 /* up_resp_wait->last_resp_wait transition on LLPORT_T_STOP */
501 bna_fw_llport_down(llport); 559 bna_fw_llport_down(llport);
502 break; 560 break;
503 561
562 case LLPORT_E_FWRESP_UP_FAIL:
504 case LLPORT_E_FWRESP_DOWN: 563 case LLPORT_E_FWRESP_DOWN:
505 bfa_fsm_set_state(llport, bna_llport_sm_stopped); 564 bfa_fsm_set_state(llport, bna_llport_sm_stopped);
506 break; 565 break;
@@ -541,7 +600,14 @@ bna_fw_cb_llport_up(void *arg, int status)
541 struct bna_llport *llport = (struct bna_llport *)arg; 600 struct bna_llport *llport = (struct bna_llport *)arg;
542 601
543 bfa_q_qe_init(&llport->mbox_qe.qe); 602 bfa_q_qe_init(&llport->mbox_qe.qe);
544 bfa_fsm_send_event(llport, LLPORT_E_FWRESP_UP); 603 if (status == BFI_LL_CMD_FAIL) {
604 if (llport->type == BNA_PORT_T_REGULAR)
605 llport->flags &= ~BNA_LLPORT_F_PORT_ENABLED;
606 else
607 llport->flags &= ~BNA_LLPORT_F_ADMIN_UP;
608 bfa_fsm_send_event(llport, LLPORT_E_FWRESP_UP_FAIL);
609 } else
610 bfa_fsm_send_event(llport, LLPORT_E_FWRESP_UP_OK);
545} 611}
546 612
547static void 613static void
@@ -588,13 +654,14 @@ bna_port_cb_llport_stopped(struct bna_port *port,
588static void 654static void
589bna_llport_init(struct bna_llport *llport, struct bna *bna) 655bna_llport_init(struct bna_llport *llport, struct bna *bna)
590{ 656{
591 llport->flags |= BNA_LLPORT_F_ENABLED; 657 llport->flags |= BNA_LLPORT_F_ADMIN_UP;
658 llport->flags |= BNA_LLPORT_F_PORT_ENABLED;
592 llport->type = BNA_PORT_T_REGULAR; 659 llport->type = BNA_PORT_T_REGULAR;
593 llport->bna = bna; 660 llport->bna = bna;
594 661
595 llport->link_status = BNA_LINK_DOWN; 662 llport->link_status = BNA_LINK_DOWN;
596 663
597 llport->admin_up_count = 0; 664 llport->rx_started_count = 0;
598 665
599 llport->stop_cbfn = NULL; 666 llport->stop_cbfn = NULL;
600 667
@@ -606,7 +673,8 @@ bna_llport_init(struct bna_llport *llport, struct bna *bna)
606static void 673static void
607bna_llport_uninit(struct bna_llport *llport) 674bna_llport_uninit(struct bna_llport *llport)
608{ 675{
609 llport->flags &= ~BNA_LLPORT_F_ENABLED; 676 llport->flags &= ~BNA_LLPORT_F_ADMIN_UP;
677 llport->flags &= ~BNA_LLPORT_F_PORT_ENABLED;
610 678
611 llport->bna = NULL; 679 llport->bna = NULL;
612} 680}
@@ -628,6 +696,8 @@ bna_llport_stop(struct bna_llport *llport)
628static void 696static void
629bna_llport_fail(struct bna_llport *llport) 697bna_llport_fail(struct bna_llport *llport)
630{ 698{
699 /* Reset the physical port status to enabled */
700 llport->flags |= BNA_LLPORT_F_PORT_ENABLED;
631 bfa_fsm_send_event(llport, LLPORT_E_FAIL); 701 bfa_fsm_send_event(llport, LLPORT_E_FAIL);
632} 702}
633 703
@@ -638,25 +708,31 @@ bna_llport_state_get(struct bna_llport *llport)
638} 708}
639 709
640void 710void
641bna_llport_admin_up(struct bna_llport *llport) 711bna_llport_rx_started(struct bna_llport *llport)
642{ 712{
643 llport->admin_up_count++; 713 llport->rx_started_count++;
714
715 if (llport->rx_started_count == 1) {
716
717 llport->flags |= BNA_LLPORT_F_RX_STARTED;
644 718
645 if (llport->admin_up_count == 1) { 719 if (llport_can_be_up(llport))
646 llport->flags |= BNA_LLPORT_F_RX_ENABLED;
647 if (llport->flags & BNA_LLPORT_F_ENABLED)
648 bfa_fsm_send_event(llport, LLPORT_E_UP); 720 bfa_fsm_send_event(llport, LLPORT_E_UP);
649 } 721 }
650} 722}
651 723
652void 724void
653bna_llport_admin_down(struct bna_llport *llport) 725bna_llport_rx_stopped(struct bna_llport *llport)
654{ 726{
655 llport->admin_up_count--; 727 int llport_up = llport_is_up(llport);
728
729 llport->rx_started_count--;
730
731 if (llport->rx_started_count == 0) {
732
733 llport->flags &= ~BNA_LLPORT_F_RX_STARTED;
656 734
657 if (llport->admin_up_count == 0) { 735 if (llport_up)
658 llport->flags &= ~BNA_LLPORT_F_RX_ENABLED;
659 if (llport->flags & BNA_LLPORT_F_ENABLED)
660 bfa_fsm_send_event(llport, LLPORT_E_DOWN); 736 bfa_fsm_send_event(llport, LLPORT_E_DOWN);
661 } 737 }
662} 738}