Lines Matching full:mbox

13 #include "mbox.h"
18 void __otx2_mbox_reset(struct otx2_mbox *mbox, int devid) in __otx2_mbox_reset() argument
20 struct otx2_mbox_dev *mdev = &mbox->dev[devid]; in __otx2_mbox_reset()
24 tx_hdr = hw_mbase + mbox->tx_start; in __otx2_mbox_reset()
25 rx_hdr = hw_mbase + mbox->rx_start; in __otx2_mbox_reset()
36 void otx2_mbox_reset(struct otx2_mbox *mbox, int devid) in otx2_mbox_reset() argument
38 struct otx2_mbox_dev *mdev = &mbox->dev[devid]; in otx2_mbox_reset()
41 __otx2_mbox_reset(mbox, devid); in otx2_mbox_reset()
46 void otx2_mbox_destroy(struct otx2_mbox *mbox) in otx2_mbox_destroy() argument
48 mbox->reg_base = NULL; in otx2_mbox_destroy()
49 mbox->hwbase = NULL; in otx2_mbox_destroy()
51 kfree(mbox->dev); in otx2_mbox_destroy()
52 mbox->dev = NULL; in otx2_mbox_destroy()
56 static int otx2_mbox_setup(struct otx2_mbox *mbox, struct pci_dev *pdev, in otx2_mbox_setup() argument
62 mbox->tx_start = MBOX_DOWN_TX_START; in otx2_mbox_setup()
63 mbox->rx_start = MBOX_DOWN_RX_START; in otx2_mbox_setup()
64 mbox->tx_size = MBOX_DOWN_TX_SIZE; in otx2_mbox_setup()
65 mbox->rx_size = MBOX_DOWN_RX_SIZE; in otx2_mbox_setup()
69 mbox->tx_start = MBOX_DOWN_RX_START; in otx2_mbox_setup()
70 mbox->rx_start = MBOX_DOWN_TX_START; in otx2_mbox_setup()
71 mbox->tx_size = MBOX_DOWN_RX_SIZE; in otx2_mbox_setup()
72 mbox->rx_size = MBOX_DOWN_TX_SIZE; in otx2_mbox_setup()
76 mbox->tx_start = MBOX_UP_TX_START; in otx2_mbox_setup()
77 mbox->rx_start = MBOX_UP_RX_START; in otx2_mbox_setup()
78 mbox->tx_size = MBOX_UP_TX_SIZE; in otx2_mbox_setup()
79 mbox->rx_size = MBOX_UP_RX_SIZE; in otx2_mbox_setup()
83 mbox->tx_start = MBOX_UP_RX_START; in otx2_mbox_setup()
84 mbox->rx_start = MBOX_UP_TX_START; in otx2_mbox_setup()
85 mbox->tx_size = MBOX_UP_RX_SIZE; in otx2_mbox_setup()
86 mbox->rx_size = MBOX_UP_TX_SIZE; in otx2_mbox_setup()
95 mbox->trigger = RVU_AF_AFPF_MBOX0; in otx2_mbox_setup()
96 mbox->tr_shift = 4; in otx2_mbox_setup()
100 mbox->trigger = RVU_PF_PFAF_MBOX1; in otx2_mbox_setup()
101 mbox->tr_shift = 0; in otx2_mbox_setup()
105 mbox->trigger = RVU_PF_VFX_PFVF_MBOX0; in otx2_mbox_setup()
106 mbox->tr_shift = 12; in otx2_mbox_setup()
110 mbox->trigger = RVU_VF_VFPF_MBOX1; in otx2_mbox_setup()
111 mbox->tr_shift = 0; in otx2_mbox_setup()
117 mbox->reg_base = reg_base; in otx2_mbox_setup()
118 mbox->pdev = pdev; in otx2_mbox_setup()
120 mbox->dev = kcalloc(ndevs, sizeof(struct otx2_mbox_dev), GFP_KERNEL); in otx2_mbox_setup()
121 if (!mbox->dev) { in otx2_mbox_setup()
122 otx2_mbox_destroy(mbox); in otx2_mbox_setup()
125 mbox->ndevs = ndevs; in otx2_mbox_setup()
130 int otx2_mbox_init(struct otx2_mbox *mbox, void *hwbase, struct pci_dev *pdev, in otx2_mbox_init() argument
136 err = otx2_mbox_setup(mbox, pdev, reg_base, direction, ndevs); in otx2_mbox_init()
140 mbox->hwbase = hwbase; in otx2_mbox_init()
143 mdev = &mbox->dev[devid]; in otx2_mbox_init()
144 mdev->mbase = mbox->hwbase + (devid * MBOX_SIZE); in otx2_mbox_init()
148 otx2_mbox_reset(mbox, devid); in otx2_mbox_init()
158 int otx2_mbox_regions_init(struct otx2_mbox *mbox, void **hwbase, in otx2_mbox_regions_init() argument
165 err = otx2_mbox_setup(mbox, pdev, reg_base, direction, ndevs); in otx2_mbox_regions_init()
169 mbox->hwbase = hwbase[0]; in otx2_mbox_regions_init()
172 mdev = &mbox->dev[devid]; in otx2_mbox_regions_init()
177 otx2_mbox_reset(mbox, devid); in otx2_mbox_regions_init()
184 int otx2_mbox_wait_for_rsp(struct otx2_mbox *mbox, int devid) in otx2_mbox_wait_for_rsp() argument
187 struct otx2_mbox_dev *mdev = &mbox->dev[devid]; in otx2_mbox_wait_for_rsp()
188 struct device *sender = &mbox->pdev->dev; in otx2_mbox_wait_for_rsp()
200 int otx2_mbox_busy_poll_for_rsp(struct otx2_mbox *mbox, int devid) in otx2_mbox_busy_poll_for_rsp() argument
202 struct otx2_mbox_dev *mdev = &mbox->dev[devid]; in otx2_mbox_busy_poll_for_rsp()
214 void otx2_mbox_msg_send(struct otx2_mbox *mbox, int devid) in otx2_mbox_msg_send() argument
216 struct otx2_mbox_dev *mdev = &mbox->dev[devid]; in otx2_mbox_msg_send()
220 tx_hdr = hw_mbase + mbox->tx_start; in otx2_mbox_msg_send()
221 rx_hdr = hw_mbase + mbox->rx_start; in otx2_mbox_msg_send()
223 /* If bounce buffer is implemented copy mbox messages from in otx2_mbox_msg_send()
224 * bounce buffer to hw mbox memory. in otx2_mbox_msg_send()
227 memcpy(hw_mbase + mbox->tx_start + msgs_offset, in otx2_mbox_msg_send()
228 mdev->mbase + mbox->tx_start + msgs_offset, in otx2_mbox_msg_send()
240 /* Sync mbox data into memory */ in otx2_mbox_msg_send()
250 trace_otx2_msg_send(mbox->pdev, tx_hdr->num_msgs, tx_hdr->msg_size); in otx2_mbox_msg_send()
257 writeq(1, (void __iomem *)mbox->reg_base + in otx2_mbox_msg_send()
258 (mbox->trigger | (devid << mbox->tr_shift))); in otx2_mbox_msg_send()
262 struct mbox_msghdr *otx2_mbox_alloc_msg_rsp(struct otx2_mbox *mbox, int devid, in otx2_mbox_alloc_msg_rsp() argument
265 struct otx2_mbox_dev *mdev = &mbox->dev[devid]; in otx2_mbox_alloc_msg_rsp()
272 if ((mdev->msg_size + size) > mbox->tx_size - msgs_offset) in otx2_mbox_alloc_msg_rsp()
274 if ((mdev->rsp_size + size_rsp) > mbox->rx_size - msgs_offset) in otx2_mbox_alloc_msg_rsp()
281 msghdr = mdev->mbase + mbox->tx_start + msgs_offset + mdev->msg_size; in otx2_mbox_alloc_msg_rsp()
297 struct mbox_msghdr *otx2_mbox_get_rsp(struct otx2_mbox *mbox, int devid, in otx2_mbox_get_rsp() argument
300 unsigned long imsg = mbox->tx_start + msgs_offset; in otx2_mbox_get_rsp()
301 unsigned long irsp = mbox->rx_start + msgs_offset; in otx2_mbox_get_rsp()
302 struct otx2_mbox_dev *mdev = &mbox->dev[devid]; in otx2_mbox_get_rsp()
321 imsg = mbox->tx_start + pmsg->next_msgoff; in otx2_mbox_get_rsp()
322 irsp = mbox->rx_start + prsp->next_msgoff; in otx2_mbox_get_rsp()
331 int otx2_mbox_check_rsp_msgs(struct otx2_mbox *mbox, int devid) in otx2_mbox_check_rsp_msgs() argument
333 unsigned long ireq = mbox->tx_start + msgs_offset; in otx2_mbox_check_rsp_msgs()
334 unsigned long irsp = mbox->rx_start + msgs_offset; in otx2_mbox_check_rsp_msgs()
335 struct otx2_mbox_dev *mdev = &mbox->dev[devid]; in otx2_mbox_check_rsp_msgs()
349 trace_otx2_msg_check(mbox->pdev, preq->id, in otx2_mbox_check_rsp_msgs()
355 trace_otx2_msg_check(mbox->pdev, preq->id, in otx2_mbox_check_rsp_msgs()
360 ireq = mbox->tx_start + preq->next_msgoff; in otx2_mbox_check_rsp_msgs()
361 irsp = mbox->rx_start + prsp->next_msgoff; in otx2_mbox_check_rsp_msgs()
371 otx2_reply_invalid_msg(struct otx2_mbox *mbox, int devid, u16 pcifunc, u16 id) in otx2_reply_invalid_msg() argument
376 otx2_mbox_alloc_msg(mbox, devid, sizeof(*rsp)); in otx2_reply_invalid_msg()
387 bool otx2_mbox_nonempty(struct otx2_mbox *mbox, int devid) in otx2_mbox_nonempty() argument
389 struct otx2_mbox_dev *mdev = &mbox->dev[devid]; in otx2_mbox_nonempty()