Commit cd47b594 authored by Mike Marciniszyn's avatar Mike Marciniszyn Committed by Jason Gunthorpe

IB/hfi1: IB/hfi1: Add an API to handle special case drop

This patch pushes special case drop logic into an API to be shared by all
interrupt handlers.

Additionally, convert do_drop to a bool.

Link: https://lore.kernel.org/r/20200106134203.119356.36962.stgit@awfm-01.aw.intel.comReviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarKaike Wan <kaike.wan@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 7b8a8b72
...@@ -1004,11 +1004,7 @@ int handle_receive_interrupt(struct hfi1_ctxtdata *rcd, int thread) ...@@ -1004,11 +1004,7 @@ int handle_receive_interrupt(struct hfi1_ctxtdata *rcd, int thread)
prescan_rxq(rcd, &packet); prescan_rxq(rcd, &packet);
while (last == RCV_PKT_OK) { while (last == RCV_PKT_OK) {
if (unlikely(dd->do_drop && if (hfi1_need_drop(dd)) {
atomic_xchg(&dd->drop_packet, DROP_PACKET_OFF) ==
DROP_PACKET_ON)) {
dd->do_drop = 0;
/* On to the next packet */ /* On to the next packet */
packet.rhqoff += packet.rsize; packet.rhqoff += packet.rsize;
packet.rhf_addr = (__le32 *)rcd->rcvhdrq + packet.rhf_addr = (__le32 *)rcd->rcvhdrq +
......
...@@ -1316,7 +1316,7 @@ struct hfi1_devdata { ...@@ -1316,7 +1316,7 @@ struct hfi1_devdata {
struct err_info_constraint err_info_xmit_constraint; struct err_info_constraint err_info_xmit_constraint;
atomic_t drop_packet; atomic_t drop_packet;
u8 do_drop; bool do_drop;
u8 err_info_uncorrectable; u8 err_info_uncorrectable;
u8 err_info_fmconfig; u8 err_info_fmconfig;
...@@ -2462,6 +2462,25 @@ static inline bool is_integrated(struct hfi1_devdata *dd) ...@@ -2462,6 +2462,25 @@ static inline bool is_integrated(struct hfi1_devdata *dd)
return dd->pcidev->device == PCI_DEVICE_ID_INTEL1; return dd->pcidev->device == PCI_DEVICE_ID_INTEL1;
} }
/**
* hfi1_need_drop - detect need for drop
* @dd: - the device
*
* In some cases, the first packet needs to be dropped.
*
* Return true is the current packet needs to be dropped and false otherwise.
*/
static inline bool hfi1_need_drop(struct hfi1_devdata *dd)
{
if (unlikely(dd->do_drop &&
atomic_xchg(&dd->drop_packet, DROP_PACKET_OFF) ==
DROP_PACKET_ON)) {
dd->do_drop = false;
return true;
}
return false;
}
int hfi1_tempsense_rd(struct hfi1_devdata *dd, struct hfi1_temp *temp); int hfi1_tempsense_rd(struct hfi1_devdata *dd, struct hfi1_temp *temp);
#define DD_DEV_ENTRY(dd) __string(dev, dev_name(&(dd)->pcidev->dev)) #define DD_DEV_ENTRY(dd) __string(dev, dev_name(&(dd)->pcidev->dev))
......
...@@ -876,10 +876,10 @@ int hfi1_init(struct hfi1_devdata *dd, int reinit) ...@@ -876,10 +876,10 @@ int hfi1_init(struct hfi1_devdata *dd, int reinit)
if (is_ax(dd)) { if (is_ax(dd)) {
atomic_set(&dd->drop_packet, DROP_PACKET_ON); atomic_set(&dd->drop_packet, DROP_PACKET_ON);
dd->do_drop = 1; dd->do_drop = true;
} else { } else {
atomic_set(&dd->drop_packet, DROP_PACKET_OFF); atomic_set(&dd->drop_packet, DROP_PACKET_OFF);
dd->do_drop = 0; dd->do_drop = false;
} }
/* make sure the link is not "up" */ /* make sure the link is not "up" */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment