ena.h (6c84cec3738e2979f3e402c69d9d3924305cee88) ena.h (7926bc4492a9a5c1e12595355d5c11121eb51f4b)
1/*-
2 * BSD LICENSE
3 *
4 * Copyright (c) 2015-2019 Amazon.com, Inc. or its affiliates.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 470 unchanged lines hidden (view full) ---

479}
480
481int ena_up(struct ena_adapter *);
482void ena_down(struct ena_adapter *);
483int ena_restore_device(struct ena_adapter *);
484void ena_destroy_device(struct ena_adapter *, bool);
485int ena_refill_rx_bufs(struct ena_ring *, uint32_t);
486
1/*-
2 * BSD LICENSE
3 *
4 * Copyright (c) 2015-2019 Amazon.com, Inc. or its affiliates.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 470 unchanged lines hidden (view full) ---

479}
480
481int ena_up(struct ena_adapter *);
482void ena_down(struct ena_adapter *);
483int ena_restore_device(struct ena_adapter *);
484void ena_destroy_device(struct ena_adapter *, bool);
485int ena_refill_rx_bufs(struct ena_ring *, uint32_t);
486
487static inline void
488ena_trigger_reset(struct ena_adapter *adapter,
489 enum ena_regs_reset_reason_types reset_reason)
490{
491 if (likely(!ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter))) {
492 adapter->reset_reason = reset_reason;
493 ENA_FLAG_SET_ATOMIC(ENA_FLAG_TRIGGER_RESET, adapter);
494 }
495}
496
487static inline int
488validate_rx_req_id(struct ena_ring *rx_ring, uint16_t req_id)
489{
490 if (likely(req_id < rx_ring->ring_size))
491 return (0);
492
493 device_printf(rx_ring->adapter->pdev, "Invalid rx req_id: %hu\n",
494 req_id);
495 counter_u64_add(rx_ring->rx_stats.bad_req_id, 1);
496
497 /* Trigger device reset */
497static inline int
498validate_rx_req_id(struct ena_ring *rx_ring, uint16_t req_id)
499{
500 if (likely(req_id < rx_ring->ring_size))
501 return (0);
502
503 device_printf(rx_ring->adapter->pdev, "Invalid rx req_id: %hu\n",
504 req_id);
505 counter_u64_add(rx_ring->rx_stats.bad_req_id, 1);
506
507 /* Trigger device reset */
498 if (likely(!ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, rx_ring->adapter))) {
499 rx_ring->adapter->reset_reason = ENA_REGS_RESET_INV_RX_REQ_ID;
500 ENA_FLAG_SET_ATOMIC(ENA_FLAG_TRIGGER_RESET, rx_ring->adapter);
501 }
508 ena_trigger_reset(rx_ring->adapter, ENA_REGS_RESET_INV_RX_REQ_ID);
502
503 return (EFAULT);
504}
505
506#endif /* !(ENA_H) */
509
510 return (EFAULT);
511}
512
513#endif /* !(ENA_H) */