cregit-Linux how code gets into the kernel

Release 4.11 drivers/net/ethernet/brocade/bna/bfa_cs.h

/*
 * Linux network driver for QLogic BR-series Converged Network Adapter.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License (GPL) Version 2 as
 * published by the Free Software Foundation
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */
/*
 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
 * Copyright (c) 2014-2015 QLogic Corporation
 * All rights reserved
 * www.qlogic.com
 */

/* BFA common services */

#ifndef __BFA_CS_H__

#define __BFA_CS_H__

#include "cna.h"

/* BFA state machine interfaces */


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

/* For converting from state machine function to state encoding. */

struct bfa_sm_table {
	
bfa_sm_t	sm;	/*!< state machine function     */
	
int		state;	/*!< state machine encoding     */
	
char		*name;	/*!< state name for display     */
};

#define BFA_SM(_sm)		((bfa_sm_t)(_sm))

/* State machine with entry actions. */

typedef void (*bfa_fsm_t)(void *fsm, int event);

/* oc - object class eg. bfa_ioc
 * st - state, eg. reset
 * 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);         \
        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);                                         \
} while (0)


#define bfa_fsm_send_event(_fsm, _event)	((_fsm)->fsm((_fsm), (_event)))

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


static inline int bfa_sm_to_state(const struct bfa_sm_table *smt, bfa_sm_t sm) { int i = 0; while (smt[i].sm && smt[i].sm != sm) i++; return smt[i].state; }

Contributors

PersonTokensPropCommitsCommitProp
Rasesh Mody50100.00%2100.00%
Total50100.00%2100.00%

/* 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++; }

Contributors

PersonTokensPropCommitsCommitProp
Rasesh Mody17100.00%1100.00%
Total17100.00%1100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Rasesh Mody34100.00%1100.00%
Total34100.00%1100.00%

/* 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); }

Contributors

PersonTokensPropCommitsCommitProp
Rasesh Mody42100.00%1100.00%
Total42100.00%1100.00%

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

Contributors

PersonTokensPropCommitsCommitProp
Rasesh Mody17100.00%1100.00%
Total17100.00%1100.00%

#endif /* __BFA_CS_H__ */

Overall Contributors

PersonTokensPropCommitsCommitProp
Rasesh Mody29897.39%480.00%
Ben Hutchings82.61%120.00%
Total306100.00%5100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.