18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * QLogic qlcnic NIC Driver
48c2ecf20Sopenharmony_ci * Copyright (c)  2009-2013 QLogic Corporation
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef __QLCNIC_DCBX_H
88c2ecf20Sopenharmony_ci#define __QLCNIC_DCBX_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#define QLCNIC_DCB_STATE	0
118c2ecf20Sopenharmony_ci#define QLCNIC_DCB_AEN_MODE	1
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#ifdef CONFIG_QLCNIC_DCB
148c2ecf20Sopenharmony_ciint qlcnic_register_dcb(struct qlcnic_adapter *);
158c2ecf20Sopenharmony_ci#else
168c2ecf20Sopenharmony_cistatic inline int qlcnic_register_dcb(struct qlcnic_adapter *adapter)
178c2ecf20Sopenharmony_ci{ return 0; }
188c2ecf20Sopenharmony_ci#endif
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_cistruct qlcnic_dcb;
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cistruct qlcnic_dcb_ops {
238c2ecf20Sopenharmony_ci	int (*query_hw_capability) (struct qlcnic_dcb *, char *);
248c2ecf20Sopenharmony_ci	int (*get_hw_capability) (struct qlcnic_dcb *);
258c2ecf20Sopenharmony_ci	int (*query_cee_param) (struct qlcnic_dcb *, char *, u8);
268c2ecf20Sopenharmony_ci	void (*init_dcbnl_ops) (struct qlcnic_dcb *);
278c2ecf20Sopenharmony_ci	void (*aen_handler) (struct qlcnic_dcb *, void *);
288c2ecf20Sopenharmony_ci	int (*get_cee_cfg) (struct qlcnic_dcb *);
298c2ecf20Sopenharmony_ci	void (*get_info) (struct qlcnic_dcb *);
308c2ecf20Sopenharmony_ci	int (*attach) (struct qlcnic_dcb *);
318c2ecf20Sopenharmony_ci	void (*free) (struct qlcnic_dcb *);
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistruct qlcnic_dcb {
358c2ecf20Sopenharmony_ci	struct qlcnic_dcb_mbx_params	*param;
368c2ecf20Sopenharmony_ci	struct qlcnic_adapter		*adapter;
378c2ecf20Sopenharmony_ci	struct delayed_work		aen_work;
388c2ecf20Sopenharmony_ci	struct workqueue_struct		*wq;
398c2ecf20Sopenharmony_ci	const struct qlcnic_dcb_ops	*ops;
408c2ecf20Sopenharmony_ci	struct qlcnic_dcb_cfg		*cfg;
418c2ecf20Sopenharmony_ci	unsigned long			state;
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistatic inline int qlcnic_dcb_get_hw_capability(struct qlcnic_dcb *dcb)
458c2ecf20Sopenharmony_ci{
468c2ecf20Sopenharmony_ci	if (dcb && dcb->ops->get_hw_capability)
478c2ecf20Sopenharmony_ci		return dcb->ops->get_hw_capability(dcb);
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	return -EOPNOTSUPP;
508c2ecf20Sopenharmony_ci}
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistatic inline void qlcnic_dcb_free(struct qlcnic_dcb *dcb)
538c2ecf20Sopenharmony_ci{
548c2ecf20Sopenharmony_ci	if (dcb && dcb->ops->free)
558c2ecf20Sopenharmony_ci		dcb->ops->free(dcb);
568c2ecf20Sopenharmony_ci}
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_cistatic inline int qlcnic_dcb_attach(struct qlcnic_dcb *dcb)
598c2ecf20Sopenharmony_ci{
608c2ecf20Sopenharmony_ci	if (dcb && dcb->ops->attach)
618c2ecf20Sopenharmony_ci		return dcb->ops->attach(dcb);
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	return -EOPNOTSUPP;
648c2ecf20Sopenharmony_ci}
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cistatic inline int
678c2ecf20Sopenharmony_ciqlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf)
688c2ecf20Sopenharmony_ci{
698c2ecf20Sopenharmony_ci	if (dcb && dcb->ops->query_hw_capability)
708c2ecf20Sopenharmony_ci		return dcb->ops->query_hw_capability(dcb, buf);
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	return -EOPNOTSUPP;
738c2ecf20Sopenharmony_ci}
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_cistatic inline void qlcnic_dcb_get_info(struct qlcnic_dcb *dcb)
768c2ecf20Sopenharmony_ci{
778c2ecf20Sopenharmony_ci	if (dcb && dcb->ops->get_info)
788c2ecf20Sopenharmony_ci		dcb->ops->get_info(dcb);
798c2ecf20Sopenharmony_ci}
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistatic inline int
828c2ecf20Sopenharmony_ciqlcnic_dcb_query_cee_param(struct qlcnic_dcb *dcb, char *buf, u8 type)
838c2ecf20Sopenharmony_ci{
848c2ecf20Sopenharmony_ci	if (dcb && dcb->ops->query_cee_param)
858c2ecf20Sopenharmony_ci		return dcb->ops->query_cee_param(dcb, buf, type);
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci	return -EOPNOTSUPP;
888c2ecf20Sopenharmony_ci}
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_cistatic inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_dcb *dcb)
918c2ecf20Sopenharmony_ci{
928c2ecf20Sopenharmony_ci	if (dcb && dcb->ops->get_cee_cfg)
938c2ecf20Sopenharmony_ci		return dcb->ops->get_cee_cfg(dcb);
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	return -EOPNOTSUPP;
968c2ecf20Sopenharmony_ci}
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cistatic inline void qlcnic_dcb_aen_handler(struct qlcnic_dcb *dcb, void *msg)
998c2ecf20Sopenharmony_ci{
1008c2ecf20Sopenharmony_ci	if (dcb && dcb->ops->aen_handler)
1018c2ecf20Sopenharmony_ci		dcb->ops->aen_handler(dcb, msg);
1028c2ecf20Sopenharmony_ci}
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cistatic inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_dcb *dcb)
1058c2ecf20Sopenharmony_ci{
1068c2ecf20Sopenharmony_ci	if (dcb && dcb->ops->init_dcbnl_ops)
1078c2ecf20Sopenharmony_ci		dcb->ops->init_dcbnl_ops(dcb);
1088c2ecf20Sopenharmony_ci}
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_cistatic inline int qlcnic_dcb_enable(struct qlcnic_dcb *dcb)
1118c2ecf20Sopenharmony_ci{
1128c2ecf20Sopenharmony_ci	return dcb ? qlcnic_dcb_attach(dcb) : 0;
1138c2ecf20Sopenharmony_ci}
1148c2ecf20Sopenharmony_ci#endif
115