18c2ecf20Sopenharmony_ci/* bnx2x_cmn.h: QLogic Everest network driver.
28c2ecf20Sopenharmony_ci *
38c2ecf20Sopenharmony_ci * Copyright (c) 2007-2013 Broadcom Corporation
48c2ecf20Sopenharmony_ci * Copyright (c) 2014 QLogic Corporation
58c2ecf20Sopenharmony_ci * All rights reserved
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
88c2ecf20Sopenharmony_ci * it under the terms of the GNU General Public License as published by
98c2ecf20Sopenharmony_ci * the Free Software Foundation.
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
128c2ecf20Sopenharmony_ci * Written by: Eliezer Tamir
138c2ecf20Sopenharmony_ci * Based on code from Michael Chan's bnx2 driver
148c2ecf20Sopenharmony_ci * UDP CSUM errata workaround by Arik Gendelman
158c2ecf20Sopenharmony_ci * Slowpath and fastpath rework by Vladislav Zolotarov
168c2ecf20Sopenharmony_ci * Statistics and Link management by Yitchak Gertner
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci */
198c2ecf20Sopenharmony_ci#ifndef BNX2X_CMN_H
208c2ecf20Sopenharmony_ci#define BNX2X_CMN_H
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#include <linux/types.h>
238c2ecf20Sopenharmony_ci#include <linux/pci.h>
248c2ecf20Sopenharmony_ci#include <linux/netdevice.h>
258c2ecf20Sopenharmony_ci#include <linux/etherdevice.h>
268c2ecf20Sopenharmony_ci#include <linux/irq.h>
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#include "bnx2x.h"
298c2ecf20Sopenharmony_ci#include "bnx2x_sriov.h"
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci/* This is used as a replacement for an MCP if it's not present */
328c2ecf20Sopenharmony_ciextern int bnx2x_load_count[2][3]; /* per-path: 0-common, 1-port0, 2-port1 */
338c2ecf20Sopenharmony_ciextern int bnx2x_num_queues;
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/************************ Macros ********************************/
368c2ecf20Sopenharmony_ci#define BNX2X_PCI_FREE(x, y, size) \
378c2ecf20Sopenharmony_ci	do { \
388c2ecf20Sopenharmony_ci		if (x) { \
398c2ecf20Sopenharmony_ci			dma_free_coherent(&bp->pdev->dev, size, (void *)x, y); \
408c2ecf20Sopenharmony_ci			x = NULL; \
418c2ecf20Sopenharmony_ci			y = 0; \
428c2ecf20Sopenharmony_ci		} \
438c2ecf20Sopenharmony_ci	} while (0)
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define BNX2X_FREE(x) \
468c2ecf20Sopenharmony_ci	do { \
478c2ecf20Sopenharmony_ci		if (x) { \
488c2ecf20Sopenharmony_ci			kfree((void *)x); \
498c2ecf20Sopenharmony_ci			x = NULL; \
508c2ecf20Sopenharmony_ci		} \
518c2ecf20Sopenharmony_ci	} while (0)
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#define BNX2X_PCI_ALLOC(y, size)					\
548c2ecf20Sopenharmony_ci({									\
558c2ecf20Sopenharmony_ci	void *x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \
568c2ecf20Sopenharmony_ci	if (x)								\
578c2ecf20Sopenharmony_ci		DP(NETIF_MSG_HW,					\
588c2ecf20Sopenharmony_ci		   "BNX2X_PCI_ALLOC: Physical %Lx Virtual %p\n",	\
598c2ecf20Sopenharmony_ci		   (unsigned long long)(*y), x);			\
608c2ecf20Sopenharmony_ci	x;								\
618c2ecf20Sopenharmony_ci})
628c2ecf20Sopenharmony_ci#define BNX2X_PCI_FALLOC(y, size)					\
638c2ecf20Sopenharmony_ci({									\
648c2ecf20Sopenharmony_ci	void *x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \
658c2ecf20Sopenharmony_ci	if (x) {							\
668c2ecf20Sopenharmony_ci		memset(x, 0xff, size);					\
678c2ecf20Sopenharmony_ci		DP(NETIF_MSG_HW,					\
688c2ecf20Sopenharmony_ci		   "BNX2X_PCI_FALLOC: Physical %Lx Virtual %p\n",	\
698c2ecf20Sopenharmony_ci		   (unsigned long long)(*y), x);			\
708c2ecf20Sopenharmony_ci	}								\
718c2ecf20Sopenharmony_ci	x;								\
728c2ecf20Sopenharmony_ci})
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci/*********************** Interfaces ****************************
758c2ecf20Sopenharmony_ci *  Functions that need to be implemented by each driver version
768c2ecf20Sopenharmony_ci */
778c2ecf20Sopenharmony_ci/* Init */
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci/**
808c2ecf20Sopenharmony_ci * bnx2x_send_unload_req - request unload mode from the MCP.
818c2ecf20Sopenharmony_ci *
828c2ecf20Sopenharmony_ci * @bp:			driver handle
838c2ecf20Sopenharmony_ci * @unload_mode:	requested function's unload mode
848c2ecf20Sopenharmony_ci *
858c2ecf20Sopenharmony_ci * Return unload mode returned by the MCP: COMMON, PORT or FUNC.
868c2ecf20Sopenharmony_ci */
878c2ecf20Sopenharmony_ciu32 bnx2x_send_unload_req(struct bnx2x *bp, int unload_mode);
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/**
908c2ecf20Sopenharmony_ci * bnx2x_send_unload_done - send UNLOAD_DONE command to the MCP.
918c2ecf20Sopenharmony_ci *
928c2ecf20Sopenharmony_ci * @bp:		driver handle
938c2ecf20Sopenharmony_ci * @keep_link:		true iff link should be kept up
948c2ecf20Sopenharmony_ci */
958c2ecf20Sopenharmony_civoid bnx2x_send_unload_done(struct bnx2x *bp, bool keep_link);
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci/**
988c2ecf20Sopenharmony_ci * bnx2x_config_rss_pf - configure RSS parameters in a PF.
998c2ecf20Sopenharmony_ci *
1008c2ecf20Sopenharmony_ci * @bp:			driver handle
1018c2ecf20Sopenharmony_ci * @rss_obj:		RSS object to use
1028c2ecf20Sopenharmony_ci * @ind_table:		indirection table to configure
1038c2ecf20Sopenharmony_ci * @config_hash:	re-configure RSS hash keys configuration
1048c2ecf20Sopenharmony_ci * @enable:		enabled or disabled configuration
1058c2ecf20Sopenharmony_ci */
1068c2ecf20Sopenharmony_ciint bnx2x_rss(struct bnx2x *bp, struct bnx2x_rss_config_obj *rss_obj,
1078c2ecf20Sopenharmony_ci	      bool config_hash, bool enable);
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci/**
1108c2ecf20Sopenharmony_ci * bnx2x__init_func_obj - init function object
1118c2ecf20Sopenharmony_ci *
1128c2ecf20Sopenharmony_ci * @bp:			driver handle
1138c2ecf20Sopenharmony_ci *
1148c2ecf20Sopenharmony_ci * Initializes the Function Object with the appropriate
1158c2ecf20Sopenharmony_ci * parameters which include a function slow path driver
1168c2ecf20Sopenharmony_ci * interface.
1178c2ecf20Sopenharmony_ci */
1188c2ecf20Sopenharmony_civoid bnx2x__init_func_obj(struct bnx2x *bp);
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci/**
1218c2ecf20Sopenharmony_ci * bnx2x_setup_queue - setup eth queue.
1228c2ecf20Sopenharmony_ci *
1238c2ecf20Sopenharmony_ci * @bp:		driver handle
1248c2ecf20Sopenharmony_ci * @fp:		pointer to the fastpath structure
1258c2ecf20Sopenharmony_ci * @leading:	boolean
1268c2ecf20Sopenharmony_ci *
1278c2ecf20Sopenharmony_ci */
1288c2ecf20Sopenharmony_ciint bnx2x_setup_queue(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1298c2ecf20Sopenharmony_ci		       bool leading);
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/**
1328c2ecf20Sopenharmony_ci * bnx2x_setup_leading - bring up a leading eth queue.
1338c2ecf20Sopenharmony_ci *
1348c2ecf20Sopenharmony_ci * @bp:		driver handle
1358c2ecf20Sopenharmony_ci */
1368c2ecf20Sopenharmony_ciint bnx2x_setup_leading(struct bnx2x *bp);
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci/**
1398c2ecf20Sopenharmony_ci * bnx2x_fw_command - send the MCP a request
1408c2ecf20Sopenharmony_ci *
1418c2ecf20Sopenharmony_ci * @bp:		driver handle
1428c2ecf20Sopenharmony_ci * @command:	request
1438c2ecf20Sopenharmony_ci * @param:	request's parameter
1448c2ecf20Sopenharmony_ci *
1458c2ecf20Sopenharmony_ci * block until there is a reply
1468c2ecf20Sopenharmony_ci */
1478c2ecf20Sopenharmony_ciu32 bnx2x_fw_command(struct bnx2x *bp, u32 command, u32 param);
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci/**
1508c2ecf20Sopenharmony_ci * bnx2x_initial_phy_init - initialize link parameters structure variables.
1518c2ecf20Sopenharmony_ci *
1528c2ecf20Sopenharmony_ci * @bp:		driver handle
1538c2ecf20Sopenharmony_ci * @load_mode:	current mode
1548c2ecf20Sopenharmony_ci */
1558c2ecf20Sopenharmony_ciint bnx2x_initial_phy_init(struct bnx2x *bp, int load_mode);
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci/**
1588c2ecf20Sopenharmony_ci * bnx2x_link_set - configure hw according to link parameters structure.
1598c2ecf20Sopenharmony_ci *
1608c2ecf20Sopenharmony_ci * @bp:		driver handle
1618c2ecf20Sopenharmony_ci */
1628c2ecf20Sopenharmony_civoid bnx2x_link_set(struct bnx2x *bp);
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci/**
1658c2ecf20Sopenharmony_ci * bnx2x_force_link_reset - Forces link reset, and put the PHY
1668c2ecf20Sopenharmony_ci * in reset as well.
1678c2ecf20Sopenharmony_ci *
1688c2ecf20Sopenharmony_ci * @bp:		driver handle
1698c2ecf20Sopenharmony_ci */
1708c2ecf20Sopenharmony_civoid bnx2x_force_link_reset(struct bnx2x *bp);
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci/**
1738c2ecf20Sopenharmony_ci * bnx2x_link_test - query link status.
1748c2ecf20Sopenharmony_ci *
1758c2ecf20Sopenharmony_ci * @bp:		driver handle
1768c2ecf20Sopenharmony_ci * @is_serdes:	bool
1778c2ecf20Sopenharmony_ci *
1788c2ecf20Sopenharmony_ci * Returns 0 if link is UP.
1798c2ecf20Sopenharmony_ci */
1808c2ecf20Sopenharmony_ciu8 bnx2x_link_test(struct bnx2x *bp, u8 is_serdes);
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci/**
1838c2ecf20Sopenharmony_ci * bnx2x_drv_pulse - write driver pulse to shmem
1848c2ecf20Sopenharmony_ci *
1858c2ecf20Sopenharmony_ci * @bp:		driver handle
1868c2ecf20Sopenharmony_ci *
1878c2ecf20Sopenharmony_ci * writes the value in bp->fw_drv_pulse_wr_seq to drv_pulse mbox
1888c2ecf20Sopenharmony_ci * in the shmem.
1898c2ecf20Sopenharmony_ci */
1908c2ecf20Sopenharmony_civoid bnx2x_drv_pulse(struct bnx2x *bp);
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci/**
1938c2ecf20Sopenharmony_ci * bnx2x_igu_ack_sb - update IGU with current SB value
1948c2ecf20Sopenharmony_ci *
1958c2ecf20Sopenharmony_ci * @bp:		driver handle
1968c2ecf20Sopenharmony_ci * @igu_sb_id:	SB id
1978c2ecf20Sopenharmony_ci * @segment:	SB segment
1988c2ecf20Sopenharmony_ci * @index:	SB index
1998c2ecf20Sopenharmony_ci * @op:		SB operation
2008c2ecf20Sopenharmony_ci * @update:	is HW update required
2018c2ecf20Sopenharmony_ci */
2028c2ecf20Sopenharmony_civoid bnx2x_igu_ack_sb(struct bnx2x *bp, u8 igu_sb_id, u8 segment,
2038c2ecf20Sopenharmony_ci		      u16 index, u8 op, u8 update);
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci/* Disable transactions from chip to host */
2068c2ecf20Sopenharmony_civoid bnx2x_pf_disable(struct bnx2x *bp);
2078c2ecf20Sopenharmony_ciint bnx2x_pretend_func(struct bnx2x *bp, u16 pretend_func_val);
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci/**
2108c2ecf20Sopenharmony_ci * bnx2x__link_status_update - handles link status change.
2118c2ecf20Sopenharmony_ci *
2128c2ecf20Sopenharmony_ci * @bp:		driver handle
2138c2ecf20Sopenharmony_ci */
2148c2ecf20Sopenharmony_civoid bnx2x__link_status_update(struct bnx2x *bp);
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci/**
2178c2ecf20Sopenharmony_ci * bnx2x_link_report - report link status to upper layer.
2188c2ecf20Sopenharmony_ci *
2198c2ecf20Sopenharmony_ci * @bp:		driver handle
2208c2ecf20Sopenharmony_ci */
2218c2ecf20Sopenharmony_civoid bnx2x_link_report(struct bnx2x *bp);
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci/* None-atomic version of bnx2x_link_report() */
2248c2ecf20Sopenharmony_civoid __bnx2x_link_report(struct bnx2x *bp);
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci/**
2278c2ecf20Sopenharmony_ci * bnx2x_get_mf_speed - calculate MF speed.
2288c2ecf20Sopenharmony_ci *
2298c2ecf20Sopenharmony_ci * @bp:		driver handle
2308c2ecf20Sopenharmony_ci *
2318c2ecf20Sopenharmony_ci * Takes into account current linespeed and MF configuration.
2328c2ecf20Sopenharmony_ci */
2338c2ecf20Sopenharmony_ciu16 bnx2x_get_mf_speed(struct bnx2x *bp);
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci/**
2368c2ecf20Sopenharmony_ci * bnx2x_msix_sp_int - MSI-X slowpath interrupt handler
2378c2ecf20Sopenharmony_ci *
2388c2ecf20Sopenharmony_ci * @irq:		irq number
2398c2ecf20Sopenharmony_ci * @dev_instance:	private instance
2408c2ecf20Sopenharmony_ci */
2418c2ecf20Sopenharmony_ciirqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance);
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci/**
2448c2ecf20Sopenharmony_ci * bnx2x_interrupt - non MSI-X interrupt handler
2458c2ecf20Sopenharmony_ci *
2468c2ecf20Sopenharmony_ci * @irq:		irq number
2478c2ecf20Sopenharmony_ci * @dev_instance:	private instance
2488c2ecf20Sopenharmony_ci */
2498c2ecf20Sopenharmony_ciirqreturn_t bnx2x_interrupt(int irq, void *dev_instance);
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci/**
2528c2ecf20Sopenharmony_ci * bnx2x_cnic_notify - send command to cnic driver
2538c2ecf20Sopenharmony_ci *
2548c2ecf20Sopenharmony_ci * @bp:		driver handle
2558c2ecf20Sopenharmony_ci * @cmd:	command
2568c2ecf20Sopenharmony_ci */
2578c2ecf20Sopenharmony_ciint bnx2x_cnic_notify(struct bnx2x *bp, int cmd);
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci/**
2608c2ecf20Sopenharmony_ci * bnx2x_setup_cnic_irq_info - provides cnic with IRQ information
2618c2ecf20Sopenharmony_ci *
2628c2ecf20Sopenharmony_ci * @bp:		driver handle
2638c2ecf20Sopenharmony_ci */
2648c2ecf20Sopenharmony_civoid bnx2x_setup_cnic_irq_info(struct bnx2x *bp);
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci/**
2678c2ecf20Sopenharmony_ci * bnx2x_setup_cnic_info - provides cnic with updated info
2688c2ecf20Sopenharmony_ci *
2698c2ecf20Sopenharmony_ci * @bp:		driver handle
2708c2ecf20Sopenharmony_ci */
2718c2ecf20Sopenharmony_civoid bnx2x_setup_cnic_info(struct bnx2x *bp);
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci/**
2748c2ecf20Sopenharmony_ci * bnx2x_int_enable - enable HW interrupts.
2758c2ecf20Sopenharmony_ci *
2768c2ecf20Sopenharmony_ci * @bp:		driver handle
2778c2ecf20Sopenharmony_ci */
2788c2ecf20Sopenharmony_civoid bnx2x_int_enable(struct bnx2x *bp);
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci/**
2818c2ecf20Sopenharmony_ci * bnx2x_int_disable_sync - disable interrupts.
2828c2ecf20Sopenharmony_ci *
2838c2ecf20Sopenharmony_ci * @bp:		driver handle
2848c2ecf20Sopenharmony_ci * @disable_hw:	true, disable HW interrupts.
2858c2ecf20Sopenharmony_ci *
2868c2ecf20Sopenharmony_ci * This function ensures that there are no
2878c2ecf20Sopenharmony_ci * ISRs or SP DPCs (sp_task) are running after it returns.
2888c2ecf20Sopenharmony_ci */
2898c2ecf20Sopenharmony_civoid bnx2x_int_disable_sync(struct bnx2x *bp, int disable_hw);
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci/**
2928c2ecf20Sopenharmony_ci * bnx2x_nic_init_cnic - init driver internals for cnic.
2938c2ecf20Sopenharmony_ci *
2948c2ecf20Sopenharmony_ci * @bp:		driver handle
2958c2ecf20Sopenharmony_ci * @load_code:	COMMON, PORT or FUNCTION
2968c2ecf20Sopenharmony_ci *
2978c2ecf20Sopenharmony_ci * Initializes:
2988c2ecf20Sopenharmony_ci *  - rings
2998c2ecf20Sopenharmony_ci *  - status blocks
3008c2ecf20Sopenharmony_ci *  - etc.
3018c2ecf20Sopenharmony_ci */
3028c2ecf20Sopenharmony_civoid bnx2x_nic_init_cnic(struct bnx2x *bp);
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci/**
3058c2ecf20Sopenharmony_ci * bnx2x_preirq_nic_init - init driver internals.
3068c2ecf20Sopenharmony_ci *
3078c2ecf20Sopenharmony_ci * @bp:		driver handle
3088c2ecf20Sopenharmony_ci *
3098c2ecf20Sopenharmony_ci * Initializes:
3108c2ecf20Sopenharmony_ci *  - fastpath object
3118c2ecf20Sopenharmony_ci *  - fastpath rings
3128c2ecf20Sopenharmony_ci *  etc.
3138c2ecf20Sopenharmony_ci */
3148c2ecf20Sopenharmony_civoid bnx2x_pre_irq_nic_init(struct bnx2x *bp);
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci/**
3178c2ecf20Sopenharmony_ci * bnx2x_postirq_nic_init - init driver internals.
3188c2ecf20Sopenharmony_ci *
3198c2ecf20Sopenharmony_ci * @bp:		driver handle
3208c2ecf20Sopenharmony_ci * @load_code:	COMMON, PORT or FUNCTION
3218c2ecf20Sopenharmony_ci *
3228c2ecf20Sopenharmony_ci * Initializes:
3238c2ecf20Sopenharmony_ci *  - status blocks
3248c2ecf20Sopenharmony_ci *  - slowpath rings
3258c2ecf20Sopenharmony_ci *  - etc.
3268c2ecf20Sopenharmony_ci */
3278c2ecf20Sopenharmony_civoid bnx2x_post_irq_nic_init(struct bnx2x *bp, u32 load_code);
3288c2ecf20Sopenharmony_ci/**
3298c2ecf20Sopenharmony_ci * bnx2x_alloc_mem_cnic - allocate driver's memory for cnic.
3308c2ecf20Sopenharmony_ci *
3318c2ecf20Sopenharmony_ci * @bp:		driver handle
3328c2ecf20Sopenharmony_ci */
3338c2ecf20Sopenharmony_ciint bnx2x_alloc_mem_cnic(struct bnx2x *bp);
3348c2ecf20Sopenharmony_ci/**
3358c2ecf20Sopenharmony_ci * bnx2x_alloc_mem - allocate driver's memory.
3368c2ecf20Sopenharmony_ci *
3378c2ecf20Sopenharmony_ci * @bp:		driver handle
3388c2ecf20Sopenharmony_ci */
3398c2ecf20Sopenharmony_ciint bnx2x_alloc_mem(struct bnx2x *bp);
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci/**
3428c2ecf20Sopenharmony_ci * bnx2x_free_mem_cnic - release driver's memory for cnic.
3438c2ecf20Sopenharmony_ci *
3448c2ecf20Sopenharmony_ci * @bp:		driver handle
3458c2ecf20Sopenharmony_ci */
3468c2ecf20Sopenharmony_civoid bnx2x_free_mem_cnic(struct bnx2x *bp);
3478c2ecf20Sopenharmony_ci/**
3488c2ecf20Sopenharmony_ci * bnx2x_free_mem - release driver's memory.
3498c2ecf20Sopenharmony_ci *
3508c2ecf20Sopenharmony_ci * @bp:		driver handle
3518c2ecf20Sopenharmony_ci */
3528c2ecf20Sopenharmony_civoid bnx2x_free_mem(struct bnx2x *bp);
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci/**
3558c2ecf20Sopenharmony_ci * bnx2x_set_num_queues - set number of queues according to mode.
3568c2ecf20Sopenharmony_ci *
3578c2ecf20Sopenharmony_ci * @bp:		driver handle
3588c2ecf20Sopenharmony_ci */
3598c2ecf20Sopenharmony_civoid bnx2x_set_num_queues(struct bnx2x *bp);
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci/**
3628c2ecf20Sopenharmony_ci * bnx2x_chip_cleanup - cleanup chip internals.
3638c2ecf20Sopenharmony_ci *
3648c2ecf20Sopenharmony_ci * @bp:			driver handle
3658c2ecf20Sopenharmony_ci * @unload_mode:	COMMON, PORT, FUNCTION
3668c2ecf20Sopenharmony_ci * @keep_link:		true iff link should be kept up.
3678c2ecf20Sopenharmony_ci *
3688c2ecf20Sopenharmony_ci * - Cleanup MAC configuration.
3698c2ecf20Sopenharmony_ci * - Closes clients.
3708c2ecf20Sopenharmony_ci * - etc.
3718c2ecf20Sopenharmony_ci */
3728c2ecf20Sopenharmony_civoid bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode, bool keep_link);
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci/**
3758c2ecf20Sopenharmony_ci * bnx2x_acquire_hw_lock - acquire HW lock.
3768c2ecf20Sopenharmony_ci *
3778c2ecf20Sopenharmony_ci * @bp:		driver handle
3788c2ecf20Sopenharmony_ci * @resource:	resource bit which was locked
3798c2ecf20Sopenharmony_ci */
3808c2ecf20Sopenharmony_ciint bnx2x_acquire_hw_lock(struct bnx2x *bp, u32 resource);
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_ci/**
3838c2ecf20Sopenharmony_ci * bnx2x_release_hw_lock - release HW lock.
3848c2ecf20Sopenharmony_ci *
3858c2ecf20Sopenharmony_ci * @bp:		driver handle
3868c2ecf20Sopenharmony_ci * @resource:	resource bit which was locked
3878c2ecf20Sopenharmony_ci */
3888c2ecf20Sopenharmony_ciint bnx2x_release_hw_lock(struct bnx2x *bp, u32 resource);
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci/**
3918c2ecf20Sopenharmony_ci * bnx2x_release_leader_lock - release recovery leader lock
3928c2ecf20Sopenharmony_ci *
3938c2ecf20Sopenharmony_ci * @bp:		driver handle
3948c2ecf20Sopenharmony_ci */
3958c2ecf20Sopenharmony_ciint bnx2x_release_leader_lock(struct bnx2x *bp);
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci/**
3988c2ecf20Sopenharmony_ci * bnx2x_set_eth_mac - configure eth MAC address in the HW
3998c2ecf20Sopenharmony_ci *
4008c2ecf20Sopenharmony_ci * @bp:		driver handle
4018c2ecf20Sopenharmony_ci * @set:	set or clear
4028c2ecf20Sopenharmony_ci *
4038c2ecf20Sopenharmony_ci * Configures according to the value in netdev->dev_addr.
4048c2ecf20Sopenharmony_ci */
4058c2ecf20Sopenharmony_ciint bnx2x_set_eth_mac(struct bnx2x *bp, bool set);
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_ci/**
4088c2ecf20Sopenharmony_ci * bnx2x_set_rx_mode - set MAC filtering configurations.
4098c2ecf20Sopenharmony_ci *
4108c2ecf20Sopenharmony_ci * @dev:	netdevice
4118c2ecf20Sopenharmony_ci *
4128c2ecf20Sopenharmony_ci * called with netif_tx_lock from dev_mcast.c
4138c2ecf20Sopenharmony_ci * If bp->state is OPEN, should be called with
4148c2ecf20Sopenharmony_ci * netif_addr_lock_bh()
4158c2ecf20Sopenharmony_ci */
4168c2ecf20Sopenharmony_civoid bnx2x_set_rx_mode_inner(struct bnx2x *bp);
4178c2ecf20Sopenharmony_ci
4188c2ecf20Sopenharmony_ci/* Parity errors related */
4198c2ecf20Sopenharmony_civoid bnx2x_set_pf_load(struct bnx2x *bp);
4208c2ecf20Sopenharmony_cibool bnx2x_clear_pf_load(struct bnx2x *bp);
4218c2ecf20Sopenharmony_cibool bnx2x_chk_parity_attn(struct bnx2x *bp, bool *global, bool print);
4228c2ecf20Sopenharmony_cibool bnx2x_reset_is_done(struct bnx2x *bp, int engine);
4238c2ecf20Sopenharmony_civoid bnx2x_set_reset_in_progress(struct bnx2x *bp);
4248c2ecf20Sopenharmony_civoid bnx2x_set_reset_global(struct bnx2x *bp);
4258c2ecf20Sopenharmony_civoid bnx2x_disable_close_the_gate(struct bnx2x *bp);
4268c2ecf20Sopenharmony_ciint bnx2x_init_hw_func_cnic(struct bnx2x *bp);
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_civoid bnx2x_clear_vlan_info(struct bnx2x *bp);
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_ci/**
4318c2ecf20Sopenharmony_ci * bnx2x_sp_event - handle ramrods completion.
4328c2ecf20Sopenharmony_ci *
4338c2ecf20Sopenharmony_ci * @fp:		fastpath handle for the event
4348c2ecf20Sopenharmony_ci * @rr_cqe:	eth_rx_cqe
4358c2ecf20Sopenharmony_ci */
4368c2ecf20Sopenharmony_civoid bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe);
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_ci/**
4398c2ecf20Sopenharmony_ci * bnx2x_ilt_set_info - prepare ILT configurations.
4408c2ecf20Sopenharmony_ci *
4418c2ecf20Sopenharmony_ci * @bp:		driver handle
4428c2ecf20Sopenharmony_ci */
4438c2ecf20Sopenharmony_civoid bnx2x_ilt_set_info(struct bnx2x *bp);
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_ci/**
4468c2ecf20Sopenharmony_ci * bnx2x_ilt_set_cnic_info - prepare ILT configurations for SRC
4478c2ecf20Sopenharmony_ci * and TM.
4488c2ecf20Sopenharmony_ci *
4498c2ecf20Sopenharmony_ci * @bp:		driver handle
4508c2ecf20Sopenharmony_ci */
4518c2ecf20Sopenharmony_civoid bnx2x_ilt_set_info_cnic(struct bnx2x *bp);
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ci/**
4548c2ecf20Sopenharmony_ci * bnx2x_dcbx_init - initialize dcbx protocol.
4558c2ecf20Sopenharmony_ci *
4568c2ecf20Sopenharmony_ci * @bp:		driver handle
4578c2ecf20Sopenharmony_ci */
4588c2ecf20Sopenharmony_civoid bnx2x_dcbx_init(struct bnx2x *bp, bool update_shmem);
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci/**
4618c2ecf20Sopenharmony_ci * bnx2x_set_power_state - set power state to the requested value.
4628c2ecf20Sopenharmony_ci *
4638c2ecf20Sopenharmony_ci * @bp:		driver handle
4648c2ecf20Sopenharmony_ci * @state:	required state D0 or D3hot
4658c2ecf20Sopenharmony_ci *
4668c2ecf20Sopenharmony_ci * Currently only D0 and D3hot are supported.
4678c2ecf20Sopenharmony_ci */
4688c2ecf20Sopenharmony_ciint bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state);
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_ci/**
4718c2ecf20Sopenharmony_ci * bnx2x_update_max_mf_config - update MAX part of MF configuration in HW.
4728c2ecf20Sopenharmony_ci *
4738c2ecf20Sopenharmony_ci * @bp:		driver handle
4748c2ecf20Sopenharmony_ci * @value:	new value
4758c2ecf20Sopenharmony_ci */
4768c2ecf20Sopenharmony_civoid bnx2x_update_max_mf_config(struct bnx2x *bp, u32 value);
4778c2ecf20Sopenharmony_ci/* Error handling */
4788c2ecf20Sopenharmony_civoid bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl);
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_ci/* dev_close main block */
4818c2ecf20Sopenharmony_ciint bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link);
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ci/* dev_open main block */
4848c2ecf20Sopenharmony_ciint bnx2x_nic_load(struct bnx2x *bp, int load_mode);
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci/* hard_xmit callback */
4878c2ecf20Sopenharmony_cinetdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev);
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_ci/* setup_tc callback */
4908c2ecf20Sopenharmony_ciint bnx2x_setup_tc(struct net_device *dev, u8 num_tc);
4918c2ecf20Sopenharmony_ciint __bnx2x_setup_tc(struct net_device *dev, enum tc_setup_type type,
4928c2ecf20Sopenharmony_ci		     void *type_data);
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ciint bnx2x_get_vf_config(struct net_device *dev, int vf,
4958c2ecf20Sopenharmony_ci			struct ifla_vf_info *ivi);
4968c2ecf20Sopenharmony_ciint bnx2x_set_vf_mac(struct net_device *dev, int queue, u8 *mac);
4978c2ecf20Sopenharmony_ciint bnx2x_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos,
4988c2ecf20Sopenharmony_ci		      __be16 vlan_proto);
4998c2ecf20Sopenharmony_ciint bnx2x_set_vf_spoofchk(struct net_device *dev, int idx, bool val);
5008c2ecf20Sopenharmony_ci
5018c2ecf20Sopenharmony_ci/* select_queue callback */
5028c2ecf20Sopenharmony_ciu16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb,
5038c2ecf20Sopenharmony_ci		       struct net_device *sb_dev);
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_cistatic inline void bnx2x_update_rx_prod(struct bnx2x *bp,
5068c2ecf20Sopenharmony_ci					struct bnx2x_fastpath *fp,
5078c2ecf20Sopenharmony_ci					u16 bd_prod, u16 rx_comp_prod,
5088c2ecf20Sopenharmony_ci					u16 rx_sge_prod)
5098c2ecf20Sopenharmony_ci{
5108c2ecf20Sopenharmony_ci	struct ustorm_eth_rx_producers rx_prods = {0};
5118c2ecf20Sopenharmony_ci	u32 i;
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_ci	/* Update producers */
5148c2ecf20Sopenharmony_ci	rx_prods.bd_prod = bd_prod;
5158c2ecf20Sopenharmony_ci	rx_prods.cqe_prod = rx_comp_prod;
5168c2ecf20Sopenharmony_ci	rx_prods.sge_prod = rx_sge_prod;
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ci	/* Make sure that the BD and SGE data is updated before updating the
5198c2ecf20Sopenharmony_ci	 * producers since FW might read the BD/SGE right after the producer
5208c2ecf20Sopenharmony_ci	 * is updated.
5218c2ecf20Sopenharmony_ci	 * This is only applicable for weak-ordered memory model archs such
5228c2ecf20Sopenharmony_ci	 * as IA-64. The following barrier is also mandatory since FW will
5238c2ecf20Sopenharmony_ci	 * assumes BDs must have buffers.
5248c2ecf20Sopenharmony_ci	 */
5258c2ecf20Sopenharmony_ci	wmb();
5268c2ecf20Sopenharmony_ci
5278c2ecf20Sopenharmony_ci	for (i = 0; i < sizeof(rx_prods)/4; i++)
5288c2ecf20Sopenharmony_ci		REG_WR_RELAXED(bp, fp->ustorm_rx_prods_offset + i * 4,
5298c2ecf20Sopenharmony_ci			       ((u32 *)&rx_prods)[i]);
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_ci	DP(NETIF_MSG_RX_STATUS,
5328c2ecf20Sopenharmony_ci	   "queue[%d]:  wrote  bd_prod %u  cqe_prod %u  sge_prod %u\n",
5338c2ecf20Sopenharmony_ci	   fp->index, bd_prod, rx_comp_prod, rx_sge_prod);
5348c2ecf20Sopenharmony_ci}
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ci/* reload helper */
5378c2ecf20Sopenharmony_ciint bnx2x_reload_if_running(struct net_device *dev);
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_ciint bnx2x_change_mac_addr(struct net_device *dev, void *p);
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ci/* NAPI poll Tx part */
5428c2ecf20Sopenharmony_ciint bnx2x_tx_int(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata);
5438c2ecf20Sopenharmony_ci
5448c2ecf20Sopenharmony_ciextern const struct dev_pm_ops bnx2x_pm_ops;
5458c2ecf20Sopenharmony_ci
5468c2ecf20Sopenharmony_ci/* Release IRQ vectors */
5478c2ecf20Sopenharmony_civoid bnx2x_free_irq(struct bnx2x *bp);
5488c2ecf20Sopenharmony_ci
5498c2ecf20Sopenharmony_civoid bnx2x_free_fp_mem(struct bnx2x *bp);
5508c2ecf20Sopenharmony_civoid bnx2x_init_rx_rings(struct bnx2x *bp);
5518c2ecf20Sopenharmony_civoid bnx2x_init_rx_rings_cnic(struct bnx2x *bp);
5528c2ecf20Sopenharmony_civoid bnx2x_free_skbs(struct bnx2x *bp);
5538c2ecf20Sopenharmony_civoid bnx2x_netif_stop(struct bnx2x *bp, int disable_hw);
5548c2ecf20Sopenharmony_civoid bnx2x_netif_start(struct bnx2x *bp);
5558c2ecf20Sopenharmony_ciint bnx2x_load_cnic(struct bnx2x *bp);
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_ci/**
5588c2ecf20Sopenharmony_ci * bnx2x_enable_msix - set msix configuration.
5598c2ecf20Sopenharmony_ci *
5608c2ecf20Sopenharmony_ci * @bp:		driver handle
5618c2ecf20Sopenharmony_ci *
5628c2ecf20Sopenharmony_ci * fills msix_table, requests vectors, updates num_queues
5638c2ecf20Sopenharmony_ci * according to number of available vectors.
5648c2ecf20Sopenharmony_ci */
5658c2ecf20Sopenharmony_ciint bnx2x_enable_msix(struct bnx2x *bp);
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_ci/**
5688c2ecf20Sopenharmony_ci * bnx2x_enable_msi - request msi mode from OS, updated internals accordingly
5698c2ecf20Sopenharmony_ci *
5708c2ecf20Sopenharmony_ci * @bp:		driver handle
5718c2ecf20Sopenharmony_ci */
5728c2ecf20Sopenharmony_ciint bnx2x_enable_msi(struct bnx2x *bp);
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_ci/**
5758c2ecf20Sopenharmony_ci * bnx2x_alloc_mem_bp - allocate memories outsize main driver structure
5768c2ecf20Sopenharmony_ci *
5778c2ecf20Sopenharmony_ci * @bp:		driver handle
5788c2ecf20Sopenharmony_ci */
5798c2ecf20Sopenharmony_ciint bnx2x_alloc_mem_bp(struct bnx2x *bp);
5808c2ecf20Sopenharmony_ci
5818c2ecf20Sopenharmony_ci/**
5828c2ecf20Sopenharmony_ci * bnx2x_free_mem_bp - release memories outsize main driver structure
5838c2ecf20Sopenharmony_ci *
5848c2ecf20Sopenharmony_ci * @bp:		driver handle
5858c2ecf20Sopenharmony_ci */
5868c2ecf20Sopenharmony_civoid bnx2x_free_mem_bp(struct bnx2x *bp);
5878c2ecf20Sopenharmony_ci
5888c2ecf20Sopenharmony_ci/**
5898c2ecf20Sopenharmony_ci * bnx2x_change_mtu - change mtu netdev callback
5908c2ecf20Sopenharmony_ci *
5918c2ecf20Sopenharmony_ci * @dev:	net device
5928c2ecf20Sopenharmony_ci * @new_mtu:	requested mtu
5938c2ecf20Sopenharmony_ci *
5948c2ecf20Sopenharmony_ci */
5958c2ecf20Sopenharmony_ciint bnx2x_change_mtu(struct net_device *dev, int new_mtu);
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_ci#ifdef NETDEV_FCOE_WWNN
5988c2ecf20Sopenharmony_ci/**
5998c2ecf20Sopenharmony_ci * bnx2x_fcoe_get_wwn - return the requested WWN value for this port
6008c2ecf20Sopenharmony_ci *
6018c2ecf20Sopenharmony_ci * @dev:	net_device
6028c2ecf20Sopenharmony_ci * @wwn:	output buffer
6038c2ecf20Sopenharmony_ci * @type:	WWN type: NETDEV_FCOE_WWNN (node) or NETDEV_FCOE_WWPN (port)
6048c2ecf20Sopenharmony_ci *
6058c2ecf20Sopenharmony_ci */
6068c2ecf20Sopenharmony_ciint bnx2x_fcoe_get_wwn(struct net_device *dev, u64 *wwn, int type);
6078c2ecf20Sopenharmony_ci#endif
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_cinetdev_features_t bnx2x_fix_features(struct net_device *dev,
6108c2ecf20Sopenharmony_ci				     netdev_features_t features);
6118c2ecf20Sopenharmony_ciint bnx2x_set_features(struct net_device *dev, netdev_features_t features);
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_ci/**
6148c2ecf20Sopenharmony_ci * bnx2x_tx_timeout - tx timeout netdev callback
6158c2ecf20Sopenharmony_ci *
6168c2ecf20Sopenharmony_ci * @dev:	net device
6178c2ecf20Sopenharmony_ci */
6188c2ecf20Sopenharmony_civoid bnx2x_tx_timeout(struct net_device *dev, unsigned int txqueue);
6198c2ecf20Sopenharmony_ci
6208c2ecf20Sopenharmony_ci/** bnx2x_get_c2s_mapping - read inner-to-outer vlan configuration
6218c2ecf20Sopenharmony_ci * c2s_map should have BNX2X_MAX_PRIORITY entries.
6228c2ecf20Sopenharmony_ci * @bp:			driver handle
6238c2ecf20Sopenharmony_ci * @c2s_map:		should have BNX2X_MAX_PRIORITY entries for mapping
6248c2ecf20Sopenharmony_ci * @c2s_default:	entry for non-tagged configuration
6258c2ecf20Sopenharmony_ci */
6268c2ecf20Sopenharmony_civoid bnx2x_get_c2s_mapping(struct bnx2x *bp, u8 *c2s_map, u8 *c2s_default);
6278c2ecf20Sopenharmony_ci
6288c2ecf20Sopenharmony_ci/*********************** Inlines **********************************/
6298c2ecf20Sopenharmony_ci/*********************** Fast path ********************************/
6308c2ecf20Sopenharmony_cistatic inline void bnx2x_update_fpsb_idx(struct bnx2x_fastpath *fp)
6318c2ecf20Sopenharmony_ci{
6328c2ecf20Sopenharmony_ci	barrier(); /* status block is written to by the chip */
6338c2ecf20Sopenharmony_ci	fp->fp_hc_idx = fp->sb_running_index[SM_RX_ID];
6348c2ecf20Sopenharmony_ci}
6358c2ecf20Sopenharmony_ci
6368c2ecf20Sopenharmony_cistatic inline void bnx2x_igu_ack_sb_gen(struct bnx2x *bp, u8 igu_sb_id,
6378c2ecf20Sopenharmony_ci					u8 segment, u16 index, u8 op,
6388c2ecf20Sopenharmony_ci					u8 update, u32 igu_addr)
6398c2ecf20Sopenharmony_ci{
6408c2ecf20Sopenharmony_ci	struct igu_regular cmd_data = {0};
6418c2ecf20Sopenharmony_ci
6428c2ecf20Sopenharmony_ci	cmd_data.sb_id_and_flags =
6438c2ecf20Sopenharmony_ci			((index << IGU_REGULAR_SB_INDEX_SHIFT) |
6448c2ecf20Sopenharmony_ci			 (segment << IGU_REGULAR_SEGMENT_ACCESS_SHIFT) |
6458c2ecf20Sopenharmony_ci			 (update << IGU_REGULAR_BUPDATE_SHIFT) |
6468c2ecf20Sopenharmony_ci			 (op << IGU_REGULAR_ENABLE_INT_SHIFT));
6478c2ecf20Sopenharmony_ci
6488c2ecf20Sopenharmony_ci	DP(NETIF_MSG_INTR, "write 0x%08x to IGU addr 0x%x\n",
6498c2ecf20Sopenharmony_ci	   cmd_data.sb_id_and_flags, igu_addr);
6508c2ecf20Sopenharmony_ci	REG_WR(bp, igu_addr, cmd_data.sb_id_and_flags);
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_ci	/* Make sure that ACK is written */
6538c2ecf20Sopenharmony_ci	barrier();
6548c2ecf20Sopenharmony_ci}
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_cistatic inline void bnx2x_hc_ack_sb(struct bnx2x *bp, u8 sb_id,
6578c2ecf20Sopenharmony_ci				   u8 storm, u16 index, u8 op, u8 update)
6588c2ecf20Sopenharmony_ci{
6598c2ecf20Sopenharmony_ci	u32 hc_addr = (HC_REG_COMMAND_REG + BP_PORT(bp)*32 +
6608c2ecf20Sopenharmony_ci		       COMMAND_REG_INT_ACK);
6618c2ecf20Sopenharmony_ci	struct igu_ack_register igu_ack;
6628c2ecf20Sopenharmony_ci
6638c2ecf20Sopenharmony_ci	igu_ack.status_block_index = index;
6648c2ecf20Sopenharmony_ci	igu_ack.sb_id_and_flags =
6658c2ecf20Sopenharmony_ci			((sb_id << IGU_ACK_REGISTER_STATUS_BLOCK_ID_SHIFT) |
6668c2ecf20Sopenharmony_ci			 (storm << IGU_ACK_REGISTER_STORM_ID_SHIFT) |
6678c2ecf20Sopenharmony_ci			 (update << IGU_ACK_REGISTER_UPDATE_INDEX_SHIFT) |
6688c2ecf20Sopenharmony_ci			 (op << IGU_ACK_REGISTER_INTERRUPT_MODE_SHIFT));
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_ci	REG_WR(bp, hc_addr, (*(u32 *)&igu_ack));
6718c2ecf20Sopenharmony_ci
6728c2ecf20Sopenharmony_ci	/* Make sure that ACK is written */
6738c2ecf20Sopenharmony_ci	barrier();
6748c2ecf20Sopenharmony_ci}
6758c2ecf20Sopenharmony_ci
6768c2ecf20Sopenharmony_cistatic inline void bnx2x_ack_sb(struct bnx2x *bp, u8 igu_sb_id, u8 storm,
6778c2ecf20Sopenharmony_ci				u16 index, u8 op, u8 update)
6788c2ecf20Sopenharmony_ci{
6798c2ecf20Sopenharmony_ci	if (bp->common.int_block == INT_BLOCK_HC)
6808c2ecf20Sopenharmony_ci		bnx2x_hc_ack_sb(bp, igu_sb_id, storm, index, op, update);
6818c2ecf20Sopenharmony_ci	else {
6828c2ecf20Sopenharmony_ci		u8 segment;
6838c2ecf20Sopenharmony_ci
6848c2ecf20Sopenharmony_ci		if (CHIP_INT_MODE_IS_BC(bp))
6858c2ecf20Sopenharmony_ci			segment = storm;
6868c2ecf20Sopenharmony_ci		else if (igu_sb_id != bp->igu_dsb_id)
6878c2ecf20Sopenharmony_ci			segment = IGU_SEG_ACCESS_DEF;
6888c2ecf20Sopenharmony_ci		else if (storm == ATTENTION_ID)
6898c2ecf20Sopenharmony_ci			segment = IGU_SEG_ACCESS_ATTN;
6908c2ecf20Sopenharmony_ci		else
6918c2ecf20Sopenharmony_ci			segment = IGU_SEG_ACCESS_DEF;
6928c2ecf20Sopenharmony_ci		bnx2x_igu_ack_sb(bp, igu_sb_id, segment, index, op, update);
6938c2ecf20Sopenharmony_ci	}
6948c2ecf20Sopenharmony_ci}
6958c2ecf20Sopenharmony_ci
6968c2ecf20Sopenharmony_cistatic inline u16 bnx2x_hc_ack_int(struct bnx2x *bp)
6978c2ecf20Sopenharmony_ci{
6988c2ecf20Sopenharmony_ci	u32 hc_addr = (HC_REG_COMMAND_REG + BP_PORT(bp)*32 +
6998c2ecf20Sopenharmony_ci		       COMMAND_REG_SIMD_MASK);
7008c2ecf20Sopenharmony_ci	u32 result = REG_RD(bp, hc_addr);
7018c2ecf20Sopenharmony_ci
7028c2ecf20Sopenharmony_ci	barrier();
7038c2ecf20Sopenharmony_ci	return result;
7048c2ecf20Sopenharmony_ci}
7058c2ecf20Sopenharmony_ci
7068c2ecf20Sopenharmony_cistatic inline u16 bnx2x_igu_ack_int(struct bnx2x *bp)
7078c2ecf20Sopenharmony_ci{
7088c2ecf20Sopenharmony_ci	u32 igu_addr = (BAR_IGU_INTMEM + IGU_REG_SISR_MDPC_WMASK_LSB_UPPER*8);
7098c2ecf20Sopenharmony_ci	u32 result = REG_RD(bp, igu_addr);
7108c2ecf20Sopenharmony_ci
7118c2ecf20Sopenharmony_ci	DP(NETIF_MSG_INTR, "read 0x%08x from IGU addr 0x%x\n",
7128c2ecf20Sopenharmony_ci	   result, igu_addr);
7138c2ecf20Sopenharmony_ci
7148c2ecf20Sopenharmony_ci	barrier();
7158c2ecf20Sopenharmony_ci	return result;
7168c2ecf20Sopenharmony_ci}
7178c2ecf20Sopenharmony_ci
7188c2ecf20Sopenharmony_cistatic inline u16 bnx2x_ack_int(struct bnx2x *bp)
7198c2ecf20Sopenharmony_ci{
7208c2ecf20Sopenharmony_ci	barrier();
7218c2ecf20Sopenharmony_ci	if (bp->common.int_block == INT_BLOCK_HC)
7228c2ecf20Sopenharmony_ci		return bnx2x_hc_ack_int(bp);
7238c2ecf20Sopenharmony_ci	else
7248c2ecf20Sopenharmony_ci		return bnx2x_igu_ack_int(bp);
7258c2ecf20Sopenharmony_ci}
7268c2ecf20Sopenharmony_ci
7278c2ecf20Sopenharmony_cistatic inline int bnx2x_has_tx_work_unload(struct bnx2x_fp_txdata *txdata)
7288c2ecf20Sopenharmony_ci{
7298c2ecf20Sopenharmony_ci	/* Tell compiler that consumer and producer can change */
7308c2ecf20Sopenharmony_ci	barrier();
7318c2ecf20Sopenharmony_ci	return txdata->tx_pkt_prod != txdata->tx_pkt_cons;
7328c2ecf20Sopenharmony_ci}
7338c2ecf20Sopenharmony_ci
7348c2ecf20Sopenharmony_cistatic inline u16 bnx2x_tx_avail(struct bnx2x *bp,
7358c2ecf20Sopenharmony_ci				 struct bnx2x_fp_txdata *txdata)
7368c2ecf20Sopenharmony_ci{
7378c2ecf20Sopenharmony_ci	s16 used;
7388c2ecf20Sopenharmony_ci	u16 prod;
7398c2ecf20Sopenharmony_ci	u16 cons;
7408c2ecf20Sopenharmony_ci
7418c2ecf20Sopenharmony_ci	prod = txdata->tx_bd_prod;
7428c2ecf20Sopenharmony_ci	cons = txdata->tx_bd_cons;
7438c2ecf20Sopenharmony_ci
7448c2ecf20Sopenharmony_ci	used = SUB_S16(prod, cons);
7458c2ecf20Sopenharmony_ci
7468c2ecf20Sopenharmony_ci#ifdef BNX2X_STOP_ON_ERROR
7478c2ecf20Sopenharmony_ci	WARN_ON(used < 0);
7488c2ecf20Sopenharmony_ci	WARN_ON(used > txdata->tx_ring_size);
7498c2ecf20Sopenharmony_ci	WARN_ON((txdata->tx_ring_size - used) > MAX_TX_AVAIL);
7508c2ecf20Sopenharmony_ci#endif
7518c2ecf20Sopenharmony_ci
7528c2ecf20Sopenharmony_ci	return (s16)(txdata->tx_ring_size) - used;
7538c2ecf20Sopenharmony_ci}
7548c2ecf20Sopenharmony_ci
7558c2ecf20Sopenharmony_cistatic inline int bnx2x_tx_queue_has_work(struct bnx2x_fp_txdata *txdata)
7568c2ecf20Sopenharmony_ci{
7578c2ecf20Sopenharmony_ci	u16 hw_cons;
7588c2ecf20Sopenharmony_ci
7598c2ecf20Sopenharmony_ci	/* Tell compiler that status block fields can change */
7608c2ecf20Sopenharmony_ci	barrier();
7618c2ecf20Sopenharmony_ci	hw_cons = le16_to_cpu(*txdata->tx_cons_sb);
7628c2ecf20Sopenharmony_ci	return hw_cons != txdata->tx_pkt_cons;
7638c2ecf20Sopenharmony_ci}
7648c2ecf20Sopenharmony_ci
7658c2ecf20Sopenharmony_cistatic inline bool bnx2x_has_tx_work(struct bnx2x_fastpath *fp)
7668c2ecf20Sopenharmony_ci{
7678c2ecf20Sopenharmony_ci	u8 cos;
7688c2ecf20Sopenharmony_ci	for_each_cos_in_tx_queue(fp, cos)
7698c2ecf20Sopenharmony_ci		if (bnx2x_tx_queue_has_work(fp->txdata_ptr[cos]))
7708c2ecf20Sopenharmony_ci			return true;
7718c2ecf20Sopenharmony_ci	return false;
7728c2ecf20Sopenharmony_ci}
7738c2ecf20Sopenharmony_ci
7748c2ecf20Sopenharmony_ci#define BNX2X_IS_CQE_COMPLETED(cqe_fp) (cqe_fp->marker == 0x0)
7758c2ecf20Sopenharmony_ci#define BNX2X_SEED_CQE(cqe_fp) (cqe_fp->marker = 0xFFFFFFFF)
7768c2ecf20Sopenharmony_cistatic inline int bnx2x_has_rx_work(struct bnx2x_fastpath *fp)
7778c2ecf20Sopenharmony_ci{
7788c2ecf20Sopenharmony_ci	u16 cons;
7798c2ecf20Sopenharmony_ci	union eth_rx_cqe *cqe;
7808c2ecf20Sopenharmony_ci	struct eth_fast_path_rx_cqe *cqe_fp;
7818c2ecf20Sopenharmony_ci
7828c2ecf20Sopenharmony_ci	cons = RCQ_BD(fp->rx_comp_cons);
7838c2ecf20Sopenharmony_ci	cqe = &fp->rx_comp_ring[cons];
7848c2ecf20Sopenharmony_ci	cqe_fp = &cqe->fast_path_cqe;
7858c2ecf20Sopenharmony_ci	return BNX2X_IS_CQE_COMPLETED(cqe_fp);
7868c2ecf20Sopenharmony_ci}
7878c2ecf20Sopenharmony_ci
7888c2ecf20Sopenharmony_ci/**
7898c2ecf20Sopenharmony_ci * bnx2x_tx_disable - disables tx from stack point of view
7908c2ecf20Sopenharmony_ci *
7918c2ecf20Sopenharmony_ci * @bp:		driver handle
7928c2ecf20Sopenharmony_ci */
7938c2ecf20Sopenharmony_cistatic inline void bnx2x_tx_disable(struct bnx2x *bp)
7948c2ecf20Sopenharmony_ci{
7958c2ecf20Sopenharmony_ci	netif_tx_disable(bp->dev);
7968c2ecf20Sopenharmony_ci	netif_carrier_off(bp->dev);
7978c2ecf20Sopenharmony_ci}
7988c2ecf20Sopenharmony_ci
7998c2ecf20Sopenharmony_cistatic inline void bnx2x_free_rx_sge(struct bnx2x *bp,
8008c2ecf20Sopenharmony_ci				     struct bnx2x_fastpath *fp, u16 index)
8018c2ecf20Sopenharmony_ci{
8028c2ecf20Sopenharmony_ci	struct sw_rx_page *sw_buf = &fp->rx_page_ring[index];
8038c2ecf20Sopenharmony_ci	struct page *page = sw_buf->page;
8048c2ecf20Sopenharmony_ci	struct eth_rx_sge *sge = &fp->rx_sge_ring[index];
8058c2ecf20Sopenharmony_ci
8068c2ecf20Sopenharmony_ci	/* Skip "next page" elements */
8078c2ecf20Sopenharmony_ci	if (!page)
8088c2ecf20Sopenharmony_ci		return;
8098c2ecf20Sopenharmony_ci
8108c2ecf20Sopenharmony_ci	/* Since many fragments can share the same page, make sure to
8118c2ecf20Sopenharmony_ci	 * only unmap and free the page once.
8128c2ecf20Sopenharmony_ci	 */
8138c2ecf20Sopenharmony_ci	dma_unmap_page(&bp->pdev->dev, dma_unmap_addr(sw_buf, mapping),
8148c2ecf20Sopenharmony_ci		       SGE_PAGE_SIZE, DMA_FROM_DEVICE);
8158c2ecf20Sopenharmony_ci
8168c2ecf20Sopenharmony_ci	put_page(page);
8178c2ecf20Sopenharmony_ci
8188c2ecf20Sopenharmony_ci	sw_buf->page = NULL;
8198c2ecf20Sopenharmony_ci	sge->addr_hi = 0;
8208c2ecf20Sopenharmony_ci	sge->addr_lo = 0;
8218c2ecf20Sopenharmony_ci}
8228c2ecf20Sopenharmony_ci
8238c2ecf20Sopenharmony_cistatic inline void bnx2x_del_all_napi_cnic(struct bnx2x *bp)
8248c2ecf20Sopenharmony_ci{
8258c2ecf20Sopenharmony_ci	int i;
8268c2ecf20Sopenharmony_ci
8278c2ecf20Sopenharmony_ci	for_each_rx_queue_cnic(bp, i) {
8288c2ecf20Sopenharmony_ci		__netif_napi_del(&bnx2x_fp(bp, i, napi));
8298c2ecf20Sopenharmony_ci	}
8308c2ecf20Sopenharmony_ci	synchronize_net();
8318c2ecf20Sopenharmony_ci}
8328c2ecf20Sopenharmony_ci
8338c2ecf20Sopenharmony_cistatic inline void bnx2x_del_all_napi(struct bnx2x *bp)
8348c2ecf20Sopenharmony_ci{
8358c2ecf20Sopenharmony_ci	int i;
8368c2ecf20Sopenharmony_ci
8378c2ecf20Sopenharmony_ci	for_each_eth_queue(bp, i) {
8388c2ecf20Sopenharmony_ci		__netif_napi_del(&bnx2x_fp(bp, i, napi));
8398c2ecf20Sopenharmony_ci	}
8408c2ecf20Sopenharmony_ci	synchronize_net();
8418c2ecf20Sopenharmony_ci}
8428c2ecf20Sopenharmony_ci
8438c2ecf20Sopenharmony_ciint bnx2x_set_int_mode(struct bnx2x *bp);
8448c2ecf20Sopenharmony_ci
8458c2ecf20Sopenharmony_cistatic inline void bnx2x_disable_msi(struct bnx2x *bp)
8468c2ecf20Sopenharmony_ci{
8478c2ecf20Sopenharmony_ci	if (bp->flags & USING_MSIX_FLAG) {
8488c2ecf20Sopenharmony_ci		pci_disable_msix(bp->pdev);
8498c2ecf20Sopenharmony_ci		bp->flags &= ~(USING_MSIX_FLAG | USING_SINGLE_MSIX_FLAG);
8508c2ecf20Sopenharmony_ci	} else if (bp->flags & USING_MSI_FLAG) {
8518c2ecf20Sopenharmony_ci		pci_disable_msi(bp->pdev);
8528c2ecf20Sopenharmony_ci		bp->flags &= ~USING_MSI_FLAG;
8538c2ecf20Sopenharmony_ci	}
8548c2ecf20Sopenharmony_ci}
8558c2ecf20Sopenharmony_ci
8568c2ecf20Sopenharmony_cistatic inline void bnx2x_clear_sge_mask_next_elems(struct bnx2x_fastpath *fp)
8578c2ecf20Sopenharmony_ci{
8588c2ecf20Sopenharmony_ci	int i, j;
8598c2ecf20Sopenharmony_ci
8608c2ecf20Sopenharmony_ci	for (i = 1; i <= NUM_RX_SGE_PAGES; i++) {
8618c2ecf20Sopenharmony_ci		int idx = RX_SGE_CNT * i - 1;
8628c2ecf20Sopenharmony_ci
8638c2ecf20Sopenharmony_ci		for (j = 0; j < 2; j++) {
8648c2ecf20Sopenharmony_ci			BIT_VEC64_CLEAR_BIT(fp->sge_mask, idx);
8658c2ecf20Sopenharmony_ci			idx--;
8668c2ecf20Sopenharmony_ci		}
8678c2ecf20Sopenharmony_ci	}
8688c2ecf20Sopenharmony_ci}
8698c2ecf20Sopenharmony_ci
8708c2ecf20Sopenharmony_cistatic inline void bnx2x_init_sge_ring_bit_mask(struct bnx2x_fastpath *fp)
8718c2ecf20Sopenharmony_ci{
8728c2ecf20Sopenharmony_ci	/* Set the mask to all 1-s: it's faster to compare to 0 than to 0xf-s */
8738c2ecf20Sopenharmony_ci	memset(fp->sge_mask, 0xff, sizeof(fp->sge_mask));
8748c2ecf20Sopenharmony_ci
8758c2ecf20Sopenharmony_ci	/* Clear the two last indices in the page to 1:
8768c2ecf20Sopenharmony_ci	   these are the indices that correspond to the "next" element,
8778c2ecf20Sopenharmony_ci	   hence will never be indicated and should be removed from
8788c2ecf20Sopenharmony_ci	   the calculations. */
8798c2ecf20Sopenharmony_ci	bnx2x_clear_sge_mask_next_elems(fp);
8808c2ecf20Sopenharmony_ci}
8818c2ecf20Sopenharmony_ci
8828c2ecf20Sopenharmony_ci/* note that we are not allocating a new buffer,
8838c2ecf20Sopenharmony_ci * we are just moving one from cons to prod
8848c2ecf20Sopenharmony_ci * we are not creating a new mapping,
8858c2ecf20Sopenharmony_ci * so there is no need to check for dma_mapping_error().
8868c2ecf20Sopenharmony_ci */
8878c2ecf20Sopenharmony_cistatic inline void bnx2x_reuse_rx_data(struct bnx2x_fastpath *fp,
8888c2ecf20Sopenharmony_ci				      u16 cons, u16 prod)
8898c2ecf20Sopenharmony_ci{
8908c2ecf20Sopenharmony_ci	struct sw_rx_bd *cons_rx_buf = &fp->rx_buf_ring[cons];
8918c2ecf20Sopenharmony_ci	struct sw_rx_bd *prod_rx_buf = &fp->rx_buf_ring[prod];
8928c2ecf20Sopenharmony_ci	struct eth_rx_bd *cons_bd = &fp->rx_desc_ring[cons];
8938c2ecf20Sopenharmony_ci	struct eth_rx_bd *prod_bd = &fp->rx_desc_ring[prod];
8948c2ecf20Sopenharmony_ci
8958c2ecf20Sopenharmony_ci	dma_unmap_addr_set(prod_rx_buf, mapping,
8968c2ecf20Sopenharmony_ci			   dma_unmap_addr(cons_rx_buf, mapping));
8978c2ecf20Sopenharmony_ci	prod_rx_buf->data = cons_rx_buf->data;
8988c2ecf20Sopenharmony_ci	*prod_bd = *cons_bd;
8998c2ecf20Sopenharmony_ci}
9008c2ecf20Sopenharmony_ci
9018c2ecf20Sopenharmony_ci/************************* Init ******************************************/
9028c2ecf20Sopenharmony_ci
9038c2ecf20Sopenharmony_ci/* returns func by VN for current port */
9048c2ecf20Sopenharmony_cistatic inline int func_by_vn(struct bnx2x *bp, int vn)
9058c2ecf20Sopenharmony_ci{
9068c2ecf20Sopenharmony_ci	return 2 * vn + BP_PORT(bp);
9078c2ecf20Sopenharmony_ci}
9088c2ecf20Sopenharmony_ci
9098c2ecf20Sopenharmony_cistatic inline int bnx2x_config_rss_eth(struct bnx2x *bp, bool config_hash)
9108c2ecf20Sopenharmony_ci{
9118c2ecf20Sopenharmony_ci	return bnx2x_rss(bp, &bp->rss_conf_obj, config_hash, true);
9128c2ecf20Sopenharmony_ci}
9138c2ecf20Sopenharmony_ci
9148c2ecf20Sopenharmony_ci/**
9158c2ecf20Sopenharmony_ci * bnx2x_func_start - init function
9168c2ecf20Sopenharmony_ci *
9178c2ecf20Sopenharmony_ci * @bp:		driver handle
9188c2ecf20Sopenharmony_ci *
9198c2ecf20Sopenharmony_ci * Must be called before sending CLIENT_SETUP for the first client.
9208c2ecf20Sopenharmony_ci */
9218c2ecf20Sopenharmony_cistatic inline int bnx2x_func_start(struct bnx2x *bp)
9228c2ecf20Sopenharmony_ci{
9238c2ecf20Sopenharmony_ci	struct bnx2x_func_state_params func_params = {NULL};
9248c2ecf20Sopenharmony_ci	struct bnx2x_func_start_params *start_params =
9258c2ecf20Sopenharmony_ci		&func_params.params.start;
9268c2ecf20Sopenharmony_ci	u16 port;
9278c2ecf20Sopenharmony_ci
9288c2ecf20Sopenharmony_ci	/* Prepare parameters for function state transitions */
9298c2ecf20Sopenharmony_ci	__set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
9308c2ecf20Sopenharmony_ci
9318c2ecf20Sopenharmony_ci	func_params.f_obj = &bp->func_obj;
9328c2ecf20Sopenharmony_ci	func_params.cmd = BNX2X_F_CMD_START;
9338c2ecf20Sopenharmony_ci
9348c2ecf20Sopenharmony_ci	/* Function parameters */
9358c2ecf20Sopenharmony_ci	start_params->mf_mode = bp->mf_mode;
9368c2ecf20Sopenharmony_ci	start_params->sd_vlan_tag = bp->mf_ov;
9378c2ecf20Sopenharmony_ci
9388c2ecf20Sopenharmony_ci	/* Configure Ethertype for BD mode */
9398c2ecf20Sopenharmony_ci	if (IS_MF_BD(bp)) {
9408c2ecf20Sopenharmony_ci		DP(NETIF_MSG_IFUP, "Configuring ethertype 0x88a8 for BD\n");
9418c2ecf20Sopenharmony_ci		start_params->sd_vlan_eth_type = ETH_P_8021AD;
9428c2ecf20Sopenharmony_ci		REG_WR(bp, PRS_REG_VLAN_TYPE_0, ETH_P_8021AD);
9438c2ecf20Sopenharmony_ci		REG_WR(bp, PBF_REG_VLAN_TYPE_0, ETH_P_8021AD);
9448c2ecf20Sopenharmony_ci		REG_WR(bp, NIG_REG_LLH_E1HOV_TYPE_1, ETH_P_8021AD);
9458c2ecf20Sopenharmony_ci
9468c2ecf20Sopenharmony_ci		bnx2x_get_c2s_mapping(bp, start_params->c2s_pri,
9478c2ecf20Sopenharmony_ci				      &start_params->c2s_pri_default);
9488c2ecf20Sopenharmony_ci		start_params->c2s_pri_valid = 1;
9498c2ecf20Sopenharmony_ci
9508c2ecf20Sopenharmony_ci		DP(NETIF_MSG_IFUP,
9518c2ecf20Sopenharmony_ci		   "Inner-to-Outer priority: %02x %02x %02x %02x %02x %02x %02x %02x [Default %02x]\n",
9528c2ecf20Sopenharmony_ci		   start_params->c2s_pri[0], start_params->c2s_pri[1],
9538c2ecf20Sopenharmony_ci		   start_params->c2s_pri[2], start_params->c2s_pri[3],
9548c2ecf20Sopenharmony_ci		   start_params->c2s_pri[4], start_params->c2s_pri[5],
9558c2ecf20Sopenharmony_ci		   start_params->c2s_pri[6], start_params->c2s_pri[7],
9568c2ecf20Sopenharmony_ci		   start_params->c2s_pri_default);
9578c2ecf20Sopenharmony_ci	}
9588c2ecf20Sopenharmony_ci
9598c2ecf20Sopenharmony_ci	if (CHIP_IS_E2(bp) || CHIP_IS_E3(bp))
9608c2ecf20Sopenharmony_ci		start_params->network_cos_mode = STATIC_COS;
9618c2ecf20Sopenharmony_ci	else /* CHIP_IS_E1X */
9628c2ecf20Sopenharmony_ci		start_params->network_cos_mode = FW_WRR;
9638c2ecf20Sopenharmony_ci	if (bp->udp_tunnel_ports[BNX2X_UDP_PORT_VXLAN]) {
9648c2ecf20Sopenharmony_ci		port = bp->udp_tunnel_ports[BNX2X_UDP_PORT_VXLAN];
9658c2ecf20Sopenharmony_ci		start_params->vxlan_dst_port = port;
9668c2ecf20Sopenharmony_ci	}
9678c2ecf20Sopenharmony_ci	if (bp->udp_tunnel_ports[BNX2X_UDP_PORT_GENEVE]) {
9688c2ecf20Sopenharmony_ci		port = bp->udp_tunnel_ports[BNX2X_UDP_PORT_GENEVE];
9698c2ecf20Sopenharmony_ci		start_params->geneve_dst_port = port;
9708c2ecf20Sopenharmony_ci	}
9718c2ecf20Sopenharmony_ci
9728c2ecf20Sopenharmony_ci	start_params->inner_rss = 1;
9738c2ecf20Sopenharmony_ci
9748c2ecf20Sopenharmony_ci	if (IS_MF_UFP(bp) && BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp)) {
9758c2ecf20Sopenharmony_ci		start_params->class_fail_ethtype = ETH_P_FIP;
9768c2ecf20Sopenharmony_ci		start_params->class_fail = 1;
9778c2ecf20Sopenharmony_ci		start_params->no_added_tags = 1;
9788c2ecf20Sopenharmony_ci	}
9798c2ecf20Sopenharmony_ci
9808c2ecf20Sopenharmony_ci	return bnx2x_func_state_change(bp, &func_params);
9818c2ecf20Sopenharmony_ci}
9828c2ecf20Sopenharmony_ci
9838c2ecf20Sopenharmony_ci/**
9848c2ecf20Sopenharmony_ci * bnx2x_set_fw_mac_addr - fill in a MAC address in FW format
9858c2ecf20Sopenharmony_ci *
9868c2ecf20Sopenharmony_ci * @fw_hi:	pointer to upper part
9878c2ecf20Sopenharmony_ci * @fw_mid:	pointer to middle part
9888c2ecf20Sopenharmony_ci * @fw_lo:	pointer to lower part
9898c2ecf20Sopenharmony_ci * @mac:	pointer to MAC address
9908c2ecf20Sopenharmony_ci */
9918c2ecf20Sopenharmony_cistatic inline void bnx2x_set_fw_mac_addr(__le16 *fw_hi, __le16 *fw_mid,
9928c2ecf20Sopenharmony_ci					 __le16 *fw_lo, u8 *mac)
9938c2ecf20Sopenharmony_ci{
9948c2ecf20Sopenharmony_ci	((u8 *)fw_hi)[0]  = mac[1];
9958c2ecf20Sopenharmony_ci	((u8 *)fw_hi)[1]  = mac[0];
9968c2ecf20Sopenharmony_ci	((u8 *)fw_mid)[0] = mac[3];
9978c2ecf20Sopenharmony_ci	((u8 *)fw_mid)[1] = mac[2];
9988c2ecf20Sopenharmony_ci	((u8 *)fw_lo)[0]  = mac[5];
9998c2ecf20Sopenharmony_ci	((u8 *)fw_lo)[1]  = mac[4];
10008c2ecf20Sopenharmony_ci}
10018c2ecf20Sopenharmony_ci
10028c2ecf20Sopenharmony_cistatic inline void bnx2x_free_rx_mem_pool(struct bnx2x *bp,
10038c2ecf20Sopenharmony_ci					  struct bnx2x_alloc_pool *pool)
10048c2ecf20Sopenharmony_ci{
10058c2ecf20Sopenharmony_ci	if (!pool->page)
10068c2ecf20Sopenharmony_ci		return;
10078c2ecf20Sopenharmony_ci
10088c2ecf20Sopenharmony_ci	put_page(pool->page);
10098c2ecf20Sopenharmony_ci
10108c2ecf20Sopenharmony_ci	pool->page = NULL;
10118c2ecf20Sopenharmony_ci}
10128c2ecf20Sopenharmony_ci
10138c2ecf20Sopenharmony_cistatic inline void bnx2x_free_rx_sge_range(struct bnx2x *bp,
10148c2ecf20Sopenharmony_ci					   struct bnx2x_fastpath *fp, int last)
10158c2ecf20Sopenharmony_ci{
10168c2ecf20Sopenharmony_ci	int i;
10178c2ecf20Sopenharmony_ci
10188c2ecf20Sopenharmony_ci	if (fp->mode == TPA_MODE_DISABLED)
10198c2ecf20Sopenharmony_ci		return;
10208c2ecf20Sopenharmony_ci
10218c2ecf20Sopenharmony_ci	for (i = 0; i < last; i++)
10228c2ecf20Sopenharmony_ci		bnx2x_free_rx_sge(bp, fp, i);
10238c2ecf20Sopenharmony_ci
10248c2ecf20Sopenharmony_ci	bnx2x_free_rx_mem_pool(bp, &fp->page_pool);
10258c2ecf20Sopenharmony_ci}
10268c2ecf20Sopenharmony_ci
10278c2ecf20Sopenharmony_cistatic inline void bnx2x_set_next_page_rx_bd(struct bnx2x_fastpath *fp)
10288c2ecf20Sopenharmony_ci{
10298c2ecf20Sopenharmony_ci	int i;
10308c2ecf20Sopenharmony_ci
10318c2ecf20Sopenharmony_ci	for (i = 1; i <= NUM_RX_RINGS; i++) {
10328c2ecf20Sopenharmony_ci		struct eth_rx_bd *rx_bd;
10338c2ecf20Sopenharmony_ci
10348c2ecf20Sopenharmony_ci		rx_bd = &fp->rx_desc_ring[RX_DESC_CNT * i - 2];
10358c2ecf20Sopenharmony_ci		rx_bd->addr_hi =
10368c2ecf20Sopenharmony_ci			cpu_to_le32(U64_HI(fp->rx_desc_mapping +
10378c2ecf20Sopenharmony_ci				    BCM_PAGE_SIZE*(i % NUM_RX_RINGS)));
10388c2ecf20Sopenharmony_ci		rx_bd->addr_lo =
10398c2ecf20Sopenharmony_ci			cpu_to_le32(U64_LO(fp->rx_desc_mapping +
10408c2ecf20Sopenharmony_ci				    BCM_PAGE_SIZE*(i % NUM_RX_RINGS)));
10418c2ecf20Sopenharmony_ci	}
10428c2ecf20Sopenharmony_ci}
10438c2ecf20Sopenharmony_ci
10448c2ecf20Sopenharmony_ci/* Statistics ID are global per chip/path, while Client IDs for E1x are per
10458c2ecf20Sopenharmony_ci * port.
10468c2ecf20Sopenharmony_ci */
10478c2ecf20Sopenharmony_cistatic inline u8 bnx2x_stats_id(struct bnx2x_fastpath *fp)
10488c2ecf20Sopenharmony_ci{
10498c2ecf20Sopenharmony_ci	struct bnx2x *bp = fp->bp;
10508c2ecf20Sopenharmony_ci	if (!CHIP_IS_E1x(bp)) {
10518c2ecf20Sopenharmony_ci		/* there are special statistics counters for FCoE 136..140 */
10528c2ecf20Sopenharmony_ci		if (IS_FCOE_FP(fp))
10538c2ecf20Sopenharmony_ci			return bp->cnic_base_cl_id + (bp->pf_num >> 1);
10548c2ecf20Sopenharmony_ci		return fp->cl_id;
10558c2ecf20Sopenharmony_ci	}
10568c2ecf20Sopenharmony_ci	return fp->cl_id + BP_PORT(bp) * FP_SB_MAX_E1x;
10578c2ecf20Sopenharmony_ci}
10588c2ecf20Sopenharmony_ci
10598c2ecf20Sopenharmony_cistatic inline void bnx2x_init_vlan_mac_fp_objs(struct bnx2x_fastpath *fp,
10608c2ecf20Sopenharmony_ci					       bnx2x_obj_type obj_type)
10618c2ecf20Sopenharmony_ci{
10628c2ecf20Sopenharmony_ci	struct bnx2x *bp = fp->bp;
10638c2ecf20Sopenharmony_ci
10648c2ecf20Sopenharmony_ci	/* Configure classification DBs */
10658c2ecf20Sopenharmony_ci	bnx2x_init_mac_obj(bp, &bnx2x_sp_obj(bp, fp).mac_obj, fp->cl_id,
10668c2ecf20Sopenharmony_ci			   fp->cid, BP_FUNC(bp), bnx2x_sp(bp, mac_rdata),
10678c2ecf20Sopenharmony_ci			   bnx2x_sp_mapping(bp, mac_rdata),
10688c2ecf20Sopenharmony_ci			   BNX2X_FILTER_MAC_PENDING,
10698c2ecf20Sopenharmony_ci			   &bp->sp_state, obj_type,
10708c2ecf20Sopenharmony_ci			   &bp->macs_pool);
10718c2ecf20Sopenharmony_ci
10728c2ecf20Sopenharmony_ci	if (!CHIP_IS_E1x(bp))
10738c2ecf20Sopenharmony_ci		bnx2x_init_vlan_obj(bp, &bnx2x_sp_obj(bp, fp).vlan_obj,
10748c2ecf20Sopenharmony_ci				    fp->cl_id, fp->cid, BP_FUNC(bp),
10758c2ecf20Sopenharmony_ci				    bnx2x_sp(bp, vlan_rdata),
10768c2ecf20Sopenharmony_ci				    bnx2x_sp_mapping(bp, vlan_rdata),
10778c2ecf20Sopenharmony_ci				    BNX2X_FILTER_VLAN_PENDING,
10788c2ecf20Sopenharmony_ci				    &bp->sp_state, obj_type,
10798c2ecf20Sopenharmony_ci				    &bp->vlans_pool);
10808c2ecf20Sopenharmony_ci}
10818c2ecf20Sopenharmony_ci
10828c2ecf20Sopenharmony_ci/**
10838c2ecf20Sopenharmony_ci * bnx2x_get_path_func_num - get number of active functions
10848c2ecf20Sopenharmony_ci *
10858c2ecf20Sopenharmony_ci * @bp:		driver handle
10868c2ecf20Sopenharmony_ci *
10878c2ecf20Sopenharmony_ci * Calculates the number of active (not hidden) functions on the
10888c2ecf20Sopenharmony_ci * current path.
10898c2ecf20Sopenharmony_ci */
10908c2ecf20Sopenharmony_cistatic inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
10918c2ecf20Sopenharmony_ci{
10928c2ecf20Sopenharmony_ci	u8 func_num = 0, i;
10938c2ecf20Sopenharmony_ci
10948c2ecf20Sopenharmony_ci	/* 57710 has only one function per-port */
10958c2ecf20Sopenharmony_ci	if (CHIP_IS_E1(bp))
10968c2ecf20Sopenharmony_ci		return 1;
10978c2ecf20Sopenharmony_ci
10988c2ecf20Sopenharmony_ci	/* Calculate a number of functions enabled on the current
10998c2ecf20Sopenharmony_ci	 * PATH/PORT.
11008c2ecf20Sopenharmony_ci	 */
11018c2ecf20Sopenharmony_ci	if (CHIP_REV_IS_SLOW(bp)) {
11028c2ecf20Sopenharmony_ci		if (IS_MF(bp))
11038c2ecf20Sopenharmony_ci			func_num = 4;
11048c2ecf20Sopenharmony_ci		else
11058c2ecf20Sopenharmony_ci			func_num = 2;
11068c2ecf20Sopenharmony_ci	} else {
11078c2ecf20Sopenharmony_ci		for (i = 0; i < E1H_FUNC_MAX / 2; i++) {
11088c2ecf20Sopenharmony_ci			u32 func_config =
11098c2ecf20Sopenharmony_ci				MF_CFG_RD(bp,
11108c2ecf20Sopenharmony_ci					  func_mf_config[BP_PATH(bp) + 2 * i].
11118c2ecf20Sopenharmony_ci					  config);
11128c2ecf20Sopenharmony_ci			func_num +=
11138c2ecf20Sopenharmony_ci				((func_config & FUNC_MF_CFG_FUNC_HIDE) ? 0 : 1);
11148c2ecf20Sopenharmony_ci		}
11158c2ecf20Sopenharmony_ci	}
11168c2ecf20Sopenharmony_ci
11178c2ecf20Sopenharmony_ci	WARN_ON(!func_num);
11188c2ecf20Sopenharmony_ci
11198c2ecf20Sopenharmony_ci	return func_num;
11208c2ecf20Sopenharmony_ci}
11218c2ecf20Sopenharmony_ci
11228c2ecf20Sopenharmony_cistatic inline void bnx2x_init_bp_objs(struct bnx2x *bp)
11238c2ecf20Sopenharmony_ci{
11248c2ecf20Sopenharmony_ci	/* RX_MODE controlling object */
11258c2ecf20Sopenharmony_ci	bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
11268c2ecf20Sopenharmony_ci
11278c2ecf20Sopenharmony_ci	/* multicast configuration controlling object */
11288c2ecf20Sopenharmony_ci	bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
11298c2ecf20Sopenharmony_ci			     BP_FUNC(bp), BP_FUNC(bp),
11308c2ecf20Sopenharmony_ci			     bnx2x_sp(bp, mcast_rdata),
11318c2ecf20Sopenharmony_ci			     bnx2x_sp_mapping(bp, mcast_rdata),
11328c2ecf20Sopenharmony_ci			     BNX2X_FILTER_MCAST_PENDING, &bp->sp_state,
11338c2ecf20Sopenharmony_ci			     BNX2X_OBJ_TYPE_RX);
11348c2ecf20Sopenharmony_ci
11358c2ecf20Sopenharmony_ci	/* Setup CAM credit pools */
11368c2ecf20Sopenharmony_ci	bnx2x_init_mac_credit_pool(bp, &bp->macs_pool, BP_FUNC(bp),
11378c2ecf20Sopenharmony_ci				   bnx2x_get_path_func_num(bp));
11388c2ecf20Sopenharmony_ci
11398c2ecf20Sopenharmony_ci	bnx2x_init_vlan_credit_pool(bp, &bp->vlans_pool, BP_FUNC(bp),
11408c2ecf20Sopenharmony_ci				    bnx2x_get_path_func_num(bp));
11418c2ecf20Sopenharmony_ci
11428c2ecf20Sopenharmony_ci	/* RSS configuration object */
11438c2ecf20Sopenharmony_ci	bnx2x_init_rss_config_obj(bp, &bp->rss_conf_obj, bp->fp->cl_id,
11448c2ecf20Sopenharmony_ci				  bp->fp->cid, BP_FUNC(bp), BP_FUNC(bp),
11458c2ecf20Sopenharmony_ci				  bnx2x_sp(bp, rss_rdata),
11468c2ecf20Sopenharmony_ci				  bnx2x_sp_mapping(bp, rss_rdata),
11478c2ecf20Sopenharmony_ci				  BNX2X_FILTER_RSS_CONF_PENDING, &bp->sp_state,
11488c2ecf20Sopenharmony_ci				  BNX2X_OBJ_TYPE_RX);
11498c2ecf20Sopenharmony_ci
11508c2ecf20Sopenharmony_ci	bp->vlan_credit = PF_VLAN_CREDIT_E2(bp, bnx2x_get_path_func_num(bp));
11518c2ecf20Sopenharmony_ci}
11528c2ecf20Sopenharmony_ci
11538c2ecf20Sopenharmony_cistatic inline u8 bnx2x_fp_qzone_id(struct bnx2x_fastpath *fp)
11548c2ecf20Sopenharmony_ci{
11558c2ecf20Sopenharmony_ci	if (CHIP_IS_E1x(fp->bp))
11568c2ecf20Sopenharmony_ci		return fp->cl_id + BP_PORT(fp->bp) * ETH_MAX_RX_CLIENTS_E1H;
11578c2ecf20Sopenharmony_ci	else
11588c2ecf20Sopenharmony_ci		return fp->cl_id;
11598c2ecf20Sopenharmony_ci}
11608c2ecf20Sopenharmony_ci
11618c2ecf20Sopenharmony_cistatic inline void bnx2x_init_txdata(struct bnx2x *bp,
11628c2ecf20Sopenharmony_ci				     struct bnx2x_fp_txdata *txdata, u32 cid,
11638c2ecf20Sopenharmony_ci				     int txq_index, __le16 *tx_cons_sb,
11648c2ecf20Sopenharmony_ci				     struct bnx2x_fastpath *fp)
11658c2ecf20Sopenharmony_ci{
11668c2ecf20Sopenharmony_ci	txdata->cid = cid;
11678c2ecf20Sopenharmony_ci	txdata->txq_index = txq_index;
11688c2ecf20Sopenharmony_ci	txdata->tx_cons_sb = tx_cons_sb;
11698c2ecf20Sopenharmony_ci	txdata->parent_fp = fp;
11708c2ecf20Sopenharmony_ci	txdata->tx_ring_size = IS_FCOE_FP(fp) ? MAX_TX_AVAIL : bp->tx_ring_size;
11718c2ecf20Sopenharmony_ci
11728c2ecf20Sopenharmony_ci	DP(NETIF_MSG_IFUP, "created tx data cid %d, txq %d\n",
11738c2ecf20Sopenharmony_ci	   txdata->cid, txdata->txq_index);
11748c2ecf20Sopenharmony_ci}
11758c2ecf20Sopenharmony_ci
11768c2ecf20Sopenharmony_cistatic inline u8 bnx2x_cnic_eth_cl_id(struct bnx2x *bp, u8 cl_idx)
11778c2ecf20Sopenharmony_ci{
11788c2ecf20Sopenharmony_ci	return bp->cnic_base_cl_id + cl_idx +
11798c2ecf20Sopenharmony_ci		(bp->pf_num >> 1) * BNX2X_MAX_CNIC_ETH_CL_ID_IDX;
11808c2ecf20Sopenharmony_ci}
11818c2ecf20Sopenharmony_ci
11828c2ecf20Sopenharmony_cistatic inline u8 bnx2x_cnic_fw_sb_id(struct bnx2x *bp)
11838c2ecf20Sopenharmony_ci{
11848c2ecf20Sopenharmony_ci	/* the 'first' id is allocated for the cnic */
11858c2ecf20Sopenharmony_ci	return bp->base_fw_ndsb;
11868c2ecf20Sopenharmony_ci}
11878c2ecf20Sopenharmony_ci
11888c2ecf20Sopenharmony_cistatic inline u8 bnx2x_cnic_igu_sb_id(struct bnx2x *bp)
11898c2ecf20Sopenharmony_ci{
11908c2ecf20Sopenharmony_ci	return bp->igu_base_sb;
11918c2ecf20Sopenharmony_ci}
11928c2ecf20Sopenharmony_ci
11938c2ecf20Sopenharmony_cistatic inline int bnx2x_clean_tx_queue(struct bnx2x *bp,
11948c2ecf20Sopenharmony_ci				       struct bnx2x_fp_txdata *txdata)
11958c2ecf20Sopenharmony_ci{
11968c2ecf20Sopenharmony_ci	int cnt = 1000;
11978c2ecf20Sopenharmony_ci
11988c2ecf20Sopenharmony_ci	while (bnx2x_has_tx_work_unload(txdata)) {
11998c2ecf20Sopenharmony_ci		if (!cnt) {
12008c2ecf20Sopenharmony_ci			BNX2X_ERR("timeout waiting for queue[%d]: txdata->tx_pkt_prod(%d) != txdata->tx_pkt_cons(%d)\n",
12018c2ecf20Sopenharmony_ci				  txdata->txq_index, txdata->tx_pkt_prod,
12028c2ecf20Sopenharmony_ci				  txdata->tx_pkt_cons);
12038c2ecf20Sopenharmony_ci#ifdef BNX2X_STOP_ON_ERROR
12048c2ecf20Sopenharmony_ci			bnx2x_panic();
12058c2ecf20Sopenharmony_ci			return -EBUSY;
12068c2ecf20Sopenharmony_ci#else
12078c2ecf20Sopenharmony_ci			break;
12088c2ecf20Sopenharmony_ci#endif
12098c2ecf20Sopenharmony_ci		}
12108c2ecf20Sopenharmony_ci		cnt--;
12118c2ecf20Sopenharmony_ci		usleep_range(1000, 2000);
12128c2ecf20Sopenharmony_ci	}
12138c2ecf20Sopenharmony_ci
12148c2ecf20Sopenharmony_ci	return 0;
12158c2ecf20Sopenharmony_ci}
12168c2ecf20Sopenharmony_ci
12178c2ecf20Sopenharmony_ciint bnx2x_get_link_cfg_idx(struct bnx2x *bp);
12188c2ecf20Sopenharmony_ci
12198c2ecf20Sopenharmony_cistatic inline void __storm_memset_struct(struct bnx2x *bp,
12208c2ecf20Sopenharmony_ci					 u32 addr, size_t size, u32 *data)
12218c2ecf20Sopenharmony_ci{
12228c2ecf20Sopenharmony_ci	int i;
12238c2ecf20Sopenharmony_ci	for (i = 0; i < size/4; i++)
12248c2ecf20Sopenharmony_ci		REG_WR(bp, addr + (i * 4), data[i]);
12258c2ecf20Sopenharmony_ci}
12268c2ecf20Sopenharmony_ci
12278c2ecf20Sopenharmony_ci/**
12288c2ecf20Sopenharmony_ci * bnx2x_wait_sp_comp - wait for the outstanding SP commands.
12298c2ecf20Sopenharmony_ci *
12308c2ecf20Sopenharmony_ci * @bp:		driver handle
12318c2ecf20Sopenharmony_ci * @mask:	bits that need to be cleared
12328c2ecf20Sopenharmony_ci */
12338c2ecf20Sopenharmony_cistatic inline bool bnx2x_wait_sp_comp(struct bnx2x *bp, unsigned long mask)
12348c2ecf20Sopenharmony_ci{
12358c2ecf20Sopenharmony_ci	int tout = 5000; /* Wait for 5 secs tops */
12368c2ecf20Sopenharmony_ci
12378c2ecf20Sopenharmony_ci	while (tout--) {
12388c2ecf20Sopenharmony_ci		smp_mb();
12398c2ecf20Sopenharmony_ci		netif_addr_lock_bh(bp->dev);
12408c2ecf20Sopenharmony_ci		if (!(bp->sp_state & mask)) {
12418c2ecf20Sopenharmony_ci			netif_addr_unlock_bh(bp->dev);
12428c2ecf20Sopenharmony_ci			return true;
12438c2ecf20Sopenharmony_ci		}
12448c2ecf20Sopenharmony_ci		netif_addr_unlock_bh(bp->dev);
12458c2ecf20Sopenharmony_ci
12468c2ecf20Sopenharmony_ci		usleep_range(1000, 2000);
12478c2ecf20Sopenharmony_ci	}
12488c2ecf20Sopenharmony_ci
12498c2ecf20Sopenharmony_ci	smp_mb();
12508c2ecf20Sopenharmony_ci
12518c2ecf20Sopenharmony_ci	netif_addr_lock_bh(bp->dev);
12528c2ecf20Sopenharmony_ci	if (bp->sp_state & mask) {
12538c2ecf20Sopenharmony_ci		BNX2X_ERR("Filtering completion timed out. sp_state 0x%lx, mask 0x%lx\n",
12548c2ecf20Sopenharmony_ci			  bp->sp_state, mask);
12558c2ecf20Sopenharmony_ci		netif_addr_unlock_bh(bp->dev);
12568c2ecf20Sopenharmony_ci		return false;
12578c2ecf20Sopenharmony_ci	}
12588c2ecf20Sopenharmony_ci	netif_addr_unlock_bh(bp->dev);
12598c2ecf20Sopenharmony_ci
12608c2ecf20Sopenharmony_ci	return true;
12618c2ecf20Sopenharmony_ci}
12628c2ecf20Sopenharmony_ci
12638c2ecf20Sopenharmony_ci/**
12648c2ecf20Sopenharmony_ci * bnx2x_set_ctx_validation - set CDU context validation values
12658c2ecf20Sopenharmony_ci *
12668c2ecf20Sopenharmony_ci * @bp:		driver handle
12678c2ecf20Sopenharmony_ci * @cxt:	context of the connection on the host memory
12688c2ecf20Sopenharmony_ci * @cid:	SW CID of the connection to be configured
12698c2ecf20Sopenharmony_ci */
12708c2ecf20Sopenharmony_civoid bnx2x_set_ctx_validation(struct bnx2x *bp, struct eth_context *cxt,
12718c2ecf20Sopenharmony_ci			      u32 cid);
12728c2ecf20Sopenharmony_ci
12738c2ecf20Sopenharmony_civoid bnx2x_update_coalesce_sb_index(struct bnx2x *bp, u8 fw_sb_id,
12748c2ecf20Sopenharmony_ci				    u8 sb_index, u8 disable, u16 usec);
12758c2ecf20Sopenharmony_civoid bnx2x_acquire_phy_lock(struct bnx2x *bp);
12768c2ecf20Sopenharmony_civoid bnx2x_release_phy_lock(struct bnx2x *bp);
12778c2ecf20Sopenharmony_ci
12788c2ecf20Sopenharmony_ci/**
12798c2ecf20Sopenharmony_ci * bnx2x_extract_max_cfg - extract MAX BW part from MF configuration.
12808c2ecf20Sopenharmony_ci *
12818c2ecf20Sopenharmony_ci * @bp:		driver handle
12828c2ecf20Sopenharmony_ci * @mf_cfg:	MF configuration
12838c2ecf20Sopenharmony_ci *
12848c2ecf20Sopenharmony_ci */
12858c2ecf20Sopenharmony_cistatic inline u16 bnx2x_extract_max_cfg(struct bnx2x *bp, u32 mf_cfg)
12868c2ecf20Sopenharmony_ci{
12878c2ecf20Sopenharmony_ci	u16 max_cfg = (mf_cfg & FUNC_MF_CFG_MAX_BW_MASK) >>
12888c2ecf20Sopenharmony_ci			      FUNC_MF_CFG_MAX_BW_SHIFT;
12898c2ecf20Sopenharmony_ci	if (!max_cfg) {
12908c2ecf20Sopenharmony_ci		DP(NETIF_MSG_IFUP | BNX2X_MSG_ETHTOOL,
12918c2ecf20Sopenharmony_ci		   "Max BW configured to 0 - using 100 instead\n");
12928c2ecf20Sopenharmony_ci		max_cfg = 100;
12938c2ecf20Sopenharmony_ci	}
12948c2ecf20Sopenharmony_ci	return max_cfg;
12958c2ecf20Sopenharmony_ci}
12968c2ecf20Sopenharmony_ci
12978c2ecf20Sopenharmony_ci/* checks if HW supports GRO for given MTU */
12988c2ecf20Sopenharmony_cistatic inline bool bnx2x_mtu_allows_gro(int mtu)
12998c2ecf20Sopenharmony_ci{
13008c2ecf20Sopenharmony_ci	/* gro frags per page */
13018c2ecf20Sopenharmony_ci	int fpp = SGE_PAGE_SIZE / (mtu - ETH_MAX_TPA_HEADER_SIZE);
13028c2ecf20Sopenharmony_ci
13038c2ecf20Sopenharmony_ci	/*
13048c2ecf20Sopenharmony_ci	 * 1. Number of frags should not grow above MAX_SKB_FRAGS
13058c2ecf20Sopenharmony_ci	 * 2. Frag must fit the page
13068c2ecf20Sopenharmony_ci	 */
13078c2ecf20Sopenharmony_ci	return mtu <= SGE_PAGE_SIZE && (U_ETH_SGL_SIZE * fpp) <= MAX_SKB_FRAGS;
13088c2ecf20Sopenharmony_ci}
13098c2ecf20Sopenharmony_ci
13108c2ecf20Sopenharmony_ci/**
13118c2ecf20Sopenharmony_ci * bnx2x_get_iscsi_info - update iSCSI params according to licensing info.
13128c2ecf20Sopenharmony_ci *
13138c2ecf20Sopenharmony_ci * @bp:		driver handle
13148c2ecf20Sopenharmony_ci *
13158c2ecf20Sopenharmony_ci */
13168c2ecf20Sopenharmony_civoid bnx2x_get_iscsi_info(struct bnx2x *bp);
13178c2ecf20Sopenharmony_ci
13188c2ecf20Sopenharmony_ci/**
13198c2ecf20Sopenharmony_ci * bnx2x_link_sync_notify - send notification to other functions.
13208c2ecf20Sopenharmony_ci *
13218c2ecf20Sopenharmony_ci * @bp:		driver handle
13228c2ecf20Sopenharmony_ci *
13238c2ecf20Sopenharmony_ci */
13248c2ecf20Sopenharmony_cistatic inline void bnx2x_link_sync_notify(struct bnx2x *bp)
13258c2ecf20Sopenharmony_ci{
13268c2ecf20Sopenharmony_ci	int func;
13278c2ecf20Sopenharmony_ci	int vn;
13288c2ecf20Sopenharmony_ci
13298c2ecf20Sopenharmony_ci	/* Set the attention towards other drivers on the same port */
13308c2ecf20Sopenharmony_ci	for (vn = VN_0; vn < BP_MAX_VN_NUM(bp); vn++) {
13318c2ecf20Sopenharmony_ci		if (vn == BP_VN(bp))
13328c2ecf20Sopenharmony_ci			continue;
13338c2ecf20Sopenharmony_ci
13348c2ecf20Sopenharmony_ci		func = func_by_vn(bp, vn);
13358c2ecf20Sopenharmony_ci		REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_0 +
13368c2ecf20Sopenharmony_ci		       (LINK_SYNC_ATTENTION_BIT_FUNC_0 + func)*4, 1);
13378c2ecf20Sopenharmony_ci	}
13388c2ecf20Sopenharmony_ci}
13398c2ecf20Sopenharmony_ci
13408c2ecf20Sopenharmony_ci/**
13418c2ecf20Sopenharmony_ci * bnx2x_update_drv_flags - update flags in shmem
13428c2ecf20Sopenharmony_ci *
13438c2ecf20Sopenharmony_ci * @bp:		driver handle
13448c2ecf20Sopenharmony_ci * @flags:	flags to update
13458c2ecf20Sopenharmony_ci * @set:	set or clear
13468c2ecf20Sopenharmony_ci *
13478c2ecf20Sopenharmony_ci */
13488c2ecf20Sopenharmony_cistatic inline void bnx2x_update_drv_flags(struct bnx2x *bp, u32 flags, u32 set)
13498c2ecf20Sopenharmony_ci{
13508c2ecf20Sopenharmony_ci	if (SHMEM2_HAS(bp, drv_flags)) {
13518c2ecf20Sopenharmony_ci		u32 drv_flags;
13528c2ecf20Sopenharmony_ci		bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_DRV_FLAGS);
13538c2ecf20Sopenharmony_ci		drv_flags = SHMEM2_RD(bp, drv_flags);
13548c2ecf20Sopenharmony_ci
13558c2ecf20Sopenharmony_ci		if (set)
13568c2ecf20Sopenharmony_ci			SET_FLAGS(drv_flags, flags);
13578c2ecf20Sopenharmony_ci		else
13588c2ecf20Sopenharmony_ci			RESET_FLAGS(drv_flags, flags);
13598c2ecf20Sopenharmony_ci
13608c2ecf20Sopenharmony_ci		SHMEM2_WR(bp, drv_flags, drv_flags);
13618c2ecf20Sopenharmony_ci		DP(NETIF_MSG_IFUP, "drv_flags 0x%08x\n", drv_flags);
13628c2ecf20Sopenharmony_ci		bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_DRV_FLAGS);
13638c2ecf20Sopenharmony_ci	}
13648c2ecf20Sopenharmony_ci}
13658c2ecf20Sopenharmony_ci
13668c2ecf20Sopenharmony_ci
13678c2ecf20Sopenharmony_ci
13688c2ecf20Sopenharmony_ci/**
13698c2ecf20Sopenharmony_ci * bnx2x_fill_fw_str - Fill buffer with FW version string
13708c2ecf20Sopenharmony_ci *
13718c2ecf20Sopenharmony_ci * @bp:        driver handle
13728c2ecf20Sopenharmony_ci * @buf:       character buffer to fill with the fw name
13738c2ecf20Sopenharmony_ci * @buf_len:   length of the above buffer
13748c2ecf20Sopenharmony_ci *
13758c2ecf20Sopenharmony_ci */
13768c2ecf20Sopenharmony_civoid bnx2x_fill_fw_str(struct bnx2x *bp, char *buf, size_t buf_len);
13778c2ecf20Sopenharmony_ci
13788c2ecf20Sopenharmony_ciint bnx2x_drain_tx_queues(struct bnx2x *bp);
13798c2ecf20Sopenharmony_civoid bnx2x_squeeze_objects(struct bnx2x *bp);
13808c2ecf20Sopenharmony_ci
13818c2ecf20Sopenharmony_civoid bnx2x_schedule_sp_rtnl(struct bnx2x*, enum sp_rtnl_flag,
13828c2ecf20Sopenharmony_ci			    u32 verbose);
13838c2ecf20Sopenharmony_ci
13848c2ecf20Sopenharmony_ci/**
13858c2ecf20Sopenharmony_ci * bnx2x_set_os_driver_state - write driver state for management FW usage
13868c2ecf20Sopenharmony_ci *
13878c2ecf20Sopenharmony_ci * @bp:		driver handle
13888c2ecf20Sopenharmony_ci * @state:	OS_DRIVER_STATE_* value reflecting current driver state
13898c2ecf20Sopenharmony_ci */
13908c2ecf20Sopenharmony_civoid bnx2x_set_os_driver_state(struct bnx2x *bp, u32 state);
13918c2ecf20Sopenharmony_ci
13928c2ecf20Sopenharmony_ci/**
13938c2ecf20Sopenharmony_ci * bnx2x_nvram_read - reads data from nvram [might sleep]
13948c2ecf20Sopenharmony_ci *
13958c2ecf20Sopenharmony_ci * @bp:		driver handle
13968c2ecf20Sopenharmony_ci * @offset:	byte offset in nvram
13978c2ecf20Sopenharmony_ci * @ret_buf:	pointer to buffer where data is to be stored
13988c2ecf20Sopenharmony_ci * @buf_size:   Length of 'ret_buf' in bytes
13998c2ecf20Sopenharmony_ci */
14008c2ecf20Sopenharmony_ciint bnx2x_nvram_read(struct bnx2x *bp, u32 offset, u8 *ret_buf,
14018c2ecf20Sopenharmony_ci		     int buf_size);
14028c2ecf20Sopenharmony_ci
14038c2ecf20Sopenharmony_ci#endif /* BNX2X_CMN_H */
1404