diff options
Diffstat (limited to 'drivers/net/benet/be_main.c')
-rw-r--r-- | drivers/net/benet/be_main.c | 182 |
1 files changed, 153 insertions, 29 deletions
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index 243172bedfa6..cff2cca3087d 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -245,14 +245,126 @@ netdev_addr: | |||
245 | return status; | 245 | return status; |
246 | } | 246 | } |
247 | 247 | ||
248 | static void populate_be2_stats(struct be_adapter *adapter) | ||
249 | { | ||
250 | |||
251 | struct be_drv_stats *drvs = &adapter->drv_stats; | ||
252 | struct be_pmem_stats *pmem_sts = be_pmem_stats_from_cmd(adapter); | ||
253 | struct be_port_rxf_stats_v0 *port_stats = | ||
254 | be_port_rxf_stats_from_cmd(adapter); | ||
255 | struct be_rxf_stats_v0 *rxf_stats = | ||
256 | be_rxf_stats_from_cmd(adapter); | ||
257 | |||
258 | drvs->rx_pause_frames = port_stats->rx_pause_frames; | ||
259 | drvs->rx_crc_errors = port_stats->rx_crc_errors; | ||
260 | drvs->rx_control_frames = port_stats->rx_control_frames; | ||
261 | drvs->rx_in_range_errors = port_stats->rx_in_range_errors; | ||
262 | drvs->rx_frame_too_long = port_stats->rx_frame_too_long; | ||
263 | drvs->rx_dropped_runt = port_stats->rx_dropped_runt; | ||
264 | drvs->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs; | ||
265 | drvs->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs; | ||
266 | drvs->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs; | ||
267 | drvs->rxpp_fifo_overflow_drop = port_stats->rx_fifo_overflow; | ||
268 | drvs->rx_dropped_tcp_length = port_stats->rx_dropped_tcp_length; | ||
269 | drvs->rx_dropped_too_small = port_stats->rx_dropped_too_small; | ||
270 | drvs->rx_dropped_too_short = port_stats->rx_dropped_too_short; | ||
271 | drvs->rx_out_range_errors = port_stats->rx_out_range_errors; | ||
272 | drvs->rx_input_fifo_overflow_drop = | ||
273 | port_stats->rx_input_fifo_overflow; | ||
274 | drvs->rx_dropped_header_too_small = | ||
275 | port_stats->rx_dropped_header_too_small; | ||
276 | drvs->rx_address_match_errors = | ||
277 | port_stats->rx_address_match_errors; | ||
278 | drvs->rx_alignment_symbol_errors = | ||
279 | port_stats->rx_alignment_symbol_errors; | ||
280 | |||
281 | drvs->tx_pauseframes = port_stats->tx_pauseframes; | ||
282 | drvs->tx_controlframes = port_stats->tx_controlframes; | ||
283 | |||
284 | if (adapter->port_num) | ||
285 | drvs->jabber_events = | ||
286 | rxf_stats->port1_jabber_events; | ||
287 | else | ||
288 | drvs->jabber_events = | ||
289 | rxf_stats->port0_jabber_events; | ||
290 | drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; | ||
291 | drvs->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb; | ||
292 | drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; | ||
293 | drvs->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring; | ||
294 | drvs->forwarded_packets = rxf_stats->forwarded_packets; | ||
295 | drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu; | ||
296 | drvs->rx_drops_no_tpre_descr = | ||
297 | rxf_stats->rx_drops_no_tpre_descr; | ||
298 | drvs->rx_drops_too_many_frags = | ||
299 | rxf_stats->rx_drops_too_many_frags; | ||
300 | adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops; | ||
301 | } | ||
302 | |||
303 | static void populate_be3_stats(struct be_adapter *adapter) | ||
304 | { | ||
305 | struct be_drv_stats *drvs = &adapter->drv_stats; | ||
306 | struct be_pmem_stats *pmem_sts = be_pmem_stats_from_cmd(adapter); | ||
307 | |||
308 | struct be_rxf_stats_v1 *rxf_stats = | ||
309 | be_rxf_stats_from_cmd(adapter); | ||
310 | struct be_port_rxf_stats_v1 *port_stats = | ||
311 | be_port_rxf_stats_from_cmd(adapter); | ||
312 | |||
313 | drvs->rx_priority_pause_frames = 0; | ||
314 | drvs->pmem_fifo_overflow_drop = 0; | ||
315 | drvs->rx_pause_frames = port_stats->rx_pause_frames; | ||
316 | drvs->rx_crc_errors = port_stats->rx_crc_errors; | ||
317 | drvs->rx_control_frames = port_stats->rx_control_frames; | ||
318 | drvs->rx_in_range_errors = port_stats->rx_in_range_errors; | ||
319 | drvs->rx_frame_too_long = port_stats->rx_frame_too_long; | ||
320 | drvs->rx_dropped_runt = port_stats->rx_dropped_runt; | ||
321 | drvs->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs; | ||
322 | drvs->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs; | ||
323 | drvs->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs; | ||
324 | drvs->rx_dropped_tcp_length = port_stats->rx_dropped_tcp_length; | ||
325 | drvs->rx_dropped_too_small = port_stats->rx_dropped_too_small; | ||
326 | drvs->rx_dropped_too_short = port_stats->rx_dropped_too_short; | ||
327 | drvs->rx_out_range_errors = port_stats->rx_out_range_errors; | ||
328 | drvs->rx_dropped_header_too_small = | ||
329 | port_stats->rx_dropped_header_too_small; | ||
330 | drvs->rx_input_fifo_overflow_drop = | ||
331 | port_stats->rx_input_fifo_overflow_drop; | ||
332 | drvs->rx_address_match_errors = | ||
333 | port_stats->rx_address_match_errors; | ||
334 | drvs->rx_alignment_symbol_errors = | ||
335 | port_stats->rx_alignment_symbol_errors; | ||
336 | drvs->rxpp_fifo_overflow_drop = | ||
337 | port_stats->rxpp_fifo_overflow_drop; | ||
338 | drvs->tx_pauseframes = port_stats->tx_pauseframes; | ||
339 | drvs->tx_controlframes = port_stats->tx_controlframes; | ||
340 | drvs->jabber_events = port_stats->jabber_events; | ||
341 | drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; | ||
342 | drvs->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb; | ||
343 | drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; | ||
344 | drvs->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring; | ||
345 | drvs->forwarded_packets = rxf_stats->forwarded_packets; | ||
346 | drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu; | ||
347 | drvs->rx_drops_no_tpre_descr = | ||
348 | rxf_stats->rx_drops_no_tpre_descr; | ||
349 | drvs->rx_drops_too_many_frags = | ||
350 | rxf_stats->rx_drops_too_many_frags; | ||
351 | adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops; | ||
352 | } | ||
353 | |||
354 | |||
355 | |||
356 | void be_parse_stats(struct be_adapter *adapter) | ||
357 | { | ||
358 | if (adapter->generation == BE_GEN3) | ||
359 | populate_be3_stats(adapter); | ||
360 | else | ||
361 | populate_be2_stats(adapter); | ||
362 | } | ||
363 | |||
248 | void netdev_stats_update(struct be_adapter *adapter) | 364 | void netdev_stats_update(struct be_adapter *adapter) |
249 | { | 365 | { |
250 | struct be_hw_stats *hw_stats = hw_stats_from_cmd(adapter->stats_cmd.va); | 366 | struct be_drv_stats *drvs = &adapter->drv_stats; |
251 | struct be_rxf_stats *rxf_stats = &hw_stats->rxf; | ||
252 | struct be_port_rxf_stats *port_stats = | ||
253 | &rxf_stats->port[adapter->port_num]; | ||
254 | struct net_device_stats *dev_stats = &adapter->netdev->stats; | 367 | struct net_device_stats *dev_stats = &adapter->netdev->stats; |
255 | struct be_erx_stats *erx_stats = &hw_stats->erx; | ||
256 | struct be_rx_obj *rxo; | 368 | struct be_rx_obj *rxo; |
257 | int i; | 369 | int i; |
258 | 370 | ||
@@ -262,43 +374,52 @@ void netdev_stats_update(struct be_adapter *adapter) | |||
262 | dev_stats->rx_bytes += rx_stats(rxo)->rx_bytes; | 374 | dev_stats->rx_bytes += rx_stats(rxo)->rx_bytes; |
263 | dev_stats->multicast += rx_stats(rxo)->rx_mcast_pkts; | 375 | dev_stats->multicast += rx_stats(rxo)->rx_mcast_pkts; |
264 | /* no space in linux buffers: best possible approximation */ | 376 | /* no space in linux buffers: best possible approximation */ |
265 | dev_stats->rx_dropped += | 377 | if (adapter->generation == BE_GEN3) { |
266 | erx_stats->rx_drops_no_fragments[rxo->q.id]; | 378 | struct be_erx_stats_v1 *erx_stats = |
379 | be_erx_stats_from_cmd(adapter); | ||
380 | dev_stats->rx_dropped += | ||
381 | erx_stats->rx_drops_no_fragments[rxo->q.id]; | ||
382 | } else { | ||
383 | struct be_erx_stats_v0 *erx_stats = | ||
384 | be_erx_stats_from_cmd(adapter); | ||
385 | dev_stats->rx_dropped += | ||
386 | erx_stats->rx_drops_no_fragments[rxo->q.id]; | ||
387 | } | ||
267 | } | 388 | } |
268 | 389 | ||
269 | dev_stats->tx_packets = tx_stats(adapter)->be_tx_pkts; | 390 | dev_stats->tx_packets = tx_stats(adapter)->be_tx_pkts; |
270 | dev_stats->tx_bytes = tx_stats(adapter)->be_tx_bytes; | 391 | dev_stats->tx_bytes = tx_stats(adapter)->be_tx_bytes; |
271 | 392 | ||
272 | /* bad pkts received */ | 393 | /* bad pkts received */ |
273 | dev_stats->rx_errors = port_stats->rx_crc_errors + | 394 | dev_stats->rx_errors = drvs->rx_crc_errors + |
274 | port_stats->rx_alignment_symbol_errors + | 395 | drvs->rx_alignment_symbol_errors + |
275 | port_stats->rx_in_range_errors + | 396 | drvs->rx_in_range_errors + |
276 | port_stats->rx_out_range_errors + | 397 | drvs->rx_out_range_errors + |
277 | port_stats->rx_frame_too_long + | 398 | drvs->rx_frame_too_long + |
278 | port_stats->rx_dropped_too_small + | 399 | drvs->rx_dropped_too_small + |
279 | port_stats->rx_dropped_too_short + | 400 | drvs->rx_dropped_too_short + |
280 | port_stats->rx_dropped_header_too_small + | 401 | drvs->rx_dropped_header_too_small + |
281 | port_stats->rx_dropped_tcp_length + | 402 | drvs->rx_dropped_tcp_length + |
282 | port_stats->rx_dropped_runt + | 403 | drvs->rx_dropped_runt + |
283 | port_stats->rx_tcp_checksum_errs + | 404 | drvs->rx_tcp_checksum_errs + |
284 | port_stats->rx_ip_checksum_errs + | 405 | drvs->rx_ip_checksum_errs + |
285 | port_stats->rx_udp_checksum_errs; | 406 | drvs->rx_udp_checksum_errs; |
286 | 407 | ||
287 | /* detailed rx errors */ | 408 | /* detailed rx errors */ |
288 | dev_stats->rx_length_errors = port_stats->rx_in_range_errors + | 409 | dev_stats->rx_length_errors = drvs->rx_in_range_errors + |
289 | port_stats->rx_out_range_errors + | 410 | drvs->rx_out_range_errors + |
290 | port_stats->rx_frame_too_long; | 411 | drvs->rx_frame_too_long; |
291 | 412 | ||
292 | dev_stats->rx_crc_errors = port_stats->rx_crc_errors; | 413 | dev_stats->rx_crc_errors = drvs->rx_crc_errors; |
293 | 414 | ||
294 | /* frame alignment errors */ | 415 | /* frame alignment errors */ |
295 | dev_stats->rx_frame_errors = port_stats->rx_alignment_symbol_errors; | 416 | dev_stats->rx_frame_errors = drvs->rx_alignment_symbol_errors; |
296 | 417 | ||
297 | /* receiver fifo overrun */ | 418 | /* receiver fifo overrun */ |
298 | /* drops_no_pbuf is no per i/f, it's per BE card */ | 419 | /* drops_no_pbuf is no per i/f, it's per BE card */ |
299 | dev_stats->rx_fifo_errors = port_stats->rx_fifo_overflow + | 420 | dev_stats->rx_fifo_errors = drvs->rxpp_fifo_overflow_drop + |
300 | port_stats->rx_input_fifo_overflow + | 421 | drvs->rx_input_fifo_overflow_drop + |
301 | rxf_stats->rx_drops_no_pbuf; | 422 | drvs->rx_drops_no_pbuf; |
302 | } | 423 | } |
303 | 424 | ||
304 | void be_link_status_update(struct be_adapter *adapter, bool link_up) | 425 | void be_link_status_update(struct be_adapter *adapter, bool link_up) |
@@ -2823,7 +2944,10 @@ static int be_stats_init(struct be_adapter *adapter) | |||
2823 | { | 2944 | { |
2824 | struct be_dma_mem *cmd = &adapter->stats_cmd; | 2945 | struct be_dma_mem *cmd = &adapter->stats_cmd; |
2825 | 2946 | ||
2826 | cmd->size = sizeof(struct be_cmd_req_get_stats); | 2947 | if (adapter->generation == BE_GEN2) |
2948 | cmd->size = sizeof(struct be_cmd_req_get_stats_v0); | ||
2949 | else | ||
2950 | cmd->size = sizeof(struct be_cmd_req_get_stats_v1); | ||
2827 | cmd->va = dma_alloc_coherent(&adapter->pdev->dev, cmd->size, &cmd->dma, | 2951 | cmd->va = dma_alloc_coherent(&adapter->pdev->dev, cmd->size, &cmd->dma, |
2828 | GFP_KERNEL); | 2952 | GFP_KERNEL); |
2829 | if (cmd->va == NULL) | 2953 | if (cmd->va == NULL) |