Skip to content

Commit

Permalink
bna: Header File Consolidation
Browse files Browse the repository at this point in the history
Change details:
 - Consolidated bfa_sm.h and bfa_wc.h into bfa_cs.h

Signed-off-by: Rasesh Mody <rmody@brocade.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Rasesh Mody authored and David S. Miller committed Jul 23, 2011
1 parent 9b08a4f commit 758ccc3
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 87 deletions.
78 changes: 65 additions & 13 deletions drivers/net/bna/bfa_sm.h → drivers/net/bna/bfa_cs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@
* General Public License for more details.
*/
/*
* Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
* Copyright (c) 2005-2011 Brocade Communications Systems, Inc.
* All rights reserved
* www.brocade.com
*/

/**
* @file bfasm.h State machine defines
* @file bfa_cs.h BFA common services
*/

#ifndef __BFA_SM_H__
#define __BFA_SM_H__
#ifndef __BFA_CS_H__
#define __BFA_CS_H__

#include "cna.h"

/**
* @ BFA state machine interfaces
*/

typedef void (*bfa_sm_t)(void *sm, int event);

/**
Expand All @@ -33,7 +37,7 @@ typedef void (*bfa_sm_t)(void *sm, int event);
* otype - object type, eg. struct bfa_ioc
* etype - object type, eg. enum ioc_event
*/
#define bfa_sm_state_decl(oc, st, otype, etype) \
#define bfa_sm_state_decl(oc, st, otype, etype) \
static void oc ## _sm_ ## st(otype * fsm, etype event)

#define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (bfa_sm_t)(_state))
Expand All @@ -49,7 +53,7 @@ struct bfa_sm_table {
int state; /*!< state machine encoding */
char *name; /*!< state name for display */
};
#define BFA_SM(_sm) ((bfa_sm_t)(_sm))
#define BFA_SM(_sm) ((bfa_sm_t)(_sm))

/**
* State machine with entry actions.
Expand All @@ -62,18 +66,18 @@ typedef void (*bfa_fsm_t)(void *fsm, int event);
* otype - object type, eg. struct bfa_ioc
* etype - object type, eg. enum ioc_event
*/
#define bfa_fsm_state_decl(oc, st, otype, etype) \
static void oc ## _sm_ ## st(otype * fsm, etype event); \
#define bfa_fsm_state_decl(oc, st, otype, etype) \
static void oc ## _sm_ ## st(otype * fsm, etype event); \
static void oc ## _sm_ ## st ## _entry(otype * fsm)

#define bfa_fsm_set_state(_fsm, _state) do { \
(_fsm)->fsm = (bfa_fsm_t)(_state); \
_state ## _entry(_fsm); \
#define bfa_fsm_set_state(_fsm, _state) do { \
(_fsm)->fsm = (bfa_fsm_t)(_state); \
_state ## _entry(_fsm); \
} while (0)

#define bfa_fsm_send_event(_fsm, _event) ((_fsm)->fsm((_fsm), (_event)))
#define bfa_fsm_get_state(_fsm) ((_fsm)->fsm)
#define bfa_fsm_cmp_state(_fsm, _state) \
#define bfa_fsm_cmp_state(_fsm, _state) \
((_fsm)->fsm == (bfa_fsm_t)(_state))

static inline int
Expand All @@ -85,4 +89,52 @@ bfa_sm_to_state(const struct bfa_sm_table *smt, bfa_sm_t sm)
i++;
return smt[i].state;
}
#endif

/**
* @ Generic wait counter.
*/

typedef void (*bfa_wc_resume_t) (void *cbarg);

struct bfa_wc {
bfa_wc_resume_t wc_resume;
void *wc_cbarg;
int wc_count;
};

static inline void
bfa_wc_up(struct bfa_wc *wc)
{
wc->wc_count++;
}

static inline void
bfa_wc_down(struct bfa_wc *wc)
{
wc->wc_count--;
if (wc->wc_count == 0)
wc->wc_resume(wc->wc_cbarg);
}

/**
* Initialize a waiting counter.
*/
static inline void
bfa_wc_init(struct bfa_wc *wc, bfa_wc_resume_t wc_resume, void *wc_cbarg)
{
wc->wc_resume = wc_resume;
wc->wc_cbarg = wc_cbarg;
wc->wc_count = 0;
bfa_wc_up(wc);
}

/**
* Wait for counter to reach zero
*/
static inline void
bfa_wc_wait(struct bfa_wc *wc)
{
bfa_wc_down(wc);
}

#endif /* __BFA_CS_H__ */
2 changes: 1 addition & 1 deletion drivers/net/bna/bfa_ioc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef __BFA_IOC_H__
#define __BFA_IOC_H__

#include "bfa_sm.h"
#include "bfa_cs.h"
#include "bfi.h"
#include "cna.h"

Expand Down
69 changes: 0 additions & 69 deletions drivers/net/bna/bfa_wc.h

This file was deleted.

2 changes: 1 addition & 1 deletion drivers/net/bna/bna.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef __BNA_H__
#define __BNA_H__

#include "bfa_wc.h"
#include "bfa_cs.h"
#include "bfa_ioc.h"
#include "cna.h"
#include "bfi_ll.h"
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/bna/bna_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
* www.brocade.com
*/
#include "bna.h"
#include "bfa_sm.h"
#include "bfa_wc.h"
#include "bfa_cs.h"

static void bna_device_cb_port_stopped(void *arg, enum bna_cb_status status);

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/bna/bna_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* www.brocade.com
*/
#include "bna.h"
#include "bfa_sm.h"
#include "bfa_cs.h"
#include "bfi.h"

/**
Expand Down

0 comments on commit 758ccc3

Please sign in to comment.