drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
Extension
.c
Size
63630 bytes
Lines
2006
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (bp->flags & BC_SUPPORTS_PFC_STATS) {
			res += offsetof(struct host_port_stats,
					pfc_frames_rx_lo) -
			       offsetof(struct host_port_stats,
					pfc_frames_tx_hi) + 4 ;
		}
	}

	res >>= 2;

	WARN_ON(res > 2 * DMAE_LEN32_RD_MAX);
	return res;
}

/*
 * Init service functions
 */

static void bnx2x_dp_stats(struct bnx2x *bp)
{
	int i;

	DP(BNX2X_MSG_STATS, "dumping stats:\n"
	   "fw_stats_req\n"
	   "    hdr\n"
	   "        cmd_num %d\n"
	   "        reserved0 %d\n"
	   "        drv_stats_counter %d\n"
	   "        reserved1 %d\n"
	   "        stats_counters_addrs %x %x\n",
	   bp->fw_stats_req->hdr.cmd_num,
	   bp->fw_stats_req->hdr.reserved0,
	   bp->fw_stats_req->hdr.drv_stats_counter,
	   bp->fw_stats_req->hdr.reserved1,
	   bp->fw_stats_req->hdr.stats_counters_addrs.hi,
	   bp->fw_stats_req->hdr.stats_counters_addrs.lo);

	for (i = 0; i < bp->fw_stats_req->hdr.cmd_num; i++) {
		DP(BNX2X_MSG_STATS,
		   "query[%d]\n"
		   "              kind %d\n"
		   "              index %d\n"
		   "              funcID %d\n"
		   "              reserved %d\n"
		   "              address %x %x\n",
		   i, bp->fw_stats_req->query[i].kind,
		   bp->fw_stats_req->query[i].index,
		   bp->fw_stats_req->query[i].funcID,
		   bp->fw_stats_req->query[i].reserved,
		   bp->fw_stats_req->query[i].address.hi,
		   bp->fw_stats_req->query[i].address.lo);
	}
}

/* Post the next statistics ramrod. Protect it with the spin in
 * order to ensure the strict order between statistics ramrods
 * (each ramrod has a sequence number passed in a
 * bp->fw_stats_req->hdr.drv_stats_counter and ramrods must be
 * sent in order).
 */
static void bnx2x_storm_stats_post(struct bnx2x *bp)
{
	int rc;

	if (bp->stats_pending)
		return;

	bp->fw_stats_req->hdr.drv_stats_counter =
		cpu_to_le16(bp->stats_counter++);

	DP(BNX2X_MSG_STATS, "Sending statistics ramrod %d\n",
	   le16_to_cpu(bp->fw_stats_req->hdr.drv_stats_counter));

	/* adjust the ramrod to include VF queues statistics */
	bnx2x_iov_adjust_stats_req(bp);
	bnx2x_dp_stats(bp);

	/* send FW stats ramrod */
	rc = bnx2x_sp_post(bp, RAMROD_CMD_ID_COMMON_STAT_QUERY, 0,
			   U64_HI(bp->fw_stats_req_mapping),
			   U64_LO(bp->fw_stats_req_mapping),
			   NONE_CONNECTION_TYPE);
	if (rc == 0)
		bp->stats_pending = 1;
}

static void bnx2x_hw_stats_post(struct bnx2x *bp)
{
	struct dmae_command *dmae = &bp->stats_dmae;
	u32 *stats_comp = bnx2x_sp(bp, stats_comp);

Annotation

Implementation Notes