Lines Matching +full:lock +full:- +full:state

7  * Copyright (c) 2003-2016 Cavium, Inc.
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
33 * Reads the 8-bytes of data from the mbox register
41 spin_lock(&mbox->lock); in octeon_mbox_read()
43 msg.u64 = readq(mbox->mbox_read_reg); in octeon_mbox_read()
46 spin_unlock(&mbox->lock); in octeon_mbox_read()
50 if (mbox->state & OCTEON_MBOX_STATE_REQUEST_RECEIVING) { in octeon_mbox_read()
51 mbox->mbox_req.data[mbox->mbox_req.recv_len - 1] = msg.u64; in octeon_mbox_read()
52 mbox->mbox_req.recv_len++; in octeon_mbox_read()
54 if (mbox->state & OCTEON_MBOX_STATE_RESPONSE_RECEIVING) { in octeon_mbox_read()
55 mbox->mbox_resp.data[mbox->mbox_resp.recv_len - 1] = in octeon_mbox_read()
57 mbox->mbox_resp.recv_len++; in octeon_mbox_read()
59 if ((mbox->state & OCTEON_MBOX_STATE_IDLE) && in octeon_mbox_read()
61 mbox->state &= ~OCTEON_MBOX_STATE_IDLE; in octeon_mbox_read()
62 mbox->state |= in octeon_mbox_read()
64 mbox->mbox_req.msg.u64 = msg.u64; in octeon_mbox_read()
65 mbox->mbox_req.q_no = mbox->q_no; in octeon_mbox_read()
66 mbox->mbox_req.recv_len = 1; in octeon_mbox_read()
68 if ((mbox->state & in octeon_mbox_read()
71 mbox->state &= in octeon_mbox_read()
73 mbox->state |= in octeon_mbox_read()
76 mbox->mbox_resp.msg.u64 = msg.u64; in octeon_mbox_read()
77 mbox->mbox_resp.q_no = mbox->q_no; in octeon_mbox_read()
78 mbox->mbox_resp.recv_len = 1; in octeon_mbox_read()
81 mbox->mbox_read_reg); in octeon_mbox_read()
82 mbox->state |= OCTEON_MBOX_STATE_ERROR; in octeon_mbox_read()
83 spin_unlock(&mbox->lock); in octeon_mbox_read()
90 if (mbox->state & OCTEON_MBOX_STATE_REQUEST_RECEIVING) { in octeon_mbox_read()
91 if (mbox->mbox_req.recv_len < mbox->mbox_req.msg.s.len) { in octeon_mbox_read()
94 mbox->state &= ~OCTEON_MBOX_STATE_REQUEST_RECEIVING; in octeon_mbox_read()
95 mbox->state |= OCTEON_MBOX_STATE_REQUEST_RECEIVED; in octeon_mbox_read()
99 if (mbox->state & OCTEON_MBOX_STATE_RESPONSE_RECEIVING) { in octeon_mbox_read()
100 if (mbox->mbox_resp.recv_len < in octeon_mbox_read()
101 mbox->mbox_resp.msg.s.len) { in octeon_mbox_read()
104 mbox->state &= in octeon_mbox_read()
106 mbox->state |= in octeon_mbox_read()
115 writeq(OCTEON_PFVFACK, mbox->mbox_read_reg); in octeon_mbox_read()
117 spin_unlock(&mbox->lock); in octeon_mbox_read()
134 struct octeon_mbox *mbox = oct->mbox[mbox_cmd->q_no]; in octeon_mbox_write()
139 spin_lock_irqsave(&mbox->lock, flags); in octeon_mbox_write()
141 if ((mbox_cmd->msg.s.type == OCTEON_MBOX_RESPONSE) && in octeon_mbox_write()
142 !(mbox->state & OCTEON_MBOX_STATE_REQUEST_RECEIVED)) { in octeon_mbox_write()
143 spin_unlock_irqrestore(&mbox->lock, flags); in octeon_mbox_write()
147 if ((mbox_cmd->msg.s.type == OCTEON_MBOX_REQUEST) && in octeon_mbox_write()
148 !(mbox->state & OCTEON_MBOX_STATE_IDLE)) { in octeon_mbox_write()
149 spin_unlock_irqrestore(&mbox->lock, flags); in octeon_mbox_write()
153 if (mbox_cmd->msg.s.type == OCTEON_MBOX_REQUEST) { in octeon_mbox_write()
154 memcpy(&mbox->mbox_resp, mbox_cmd, in octeon_mbox_write()
156 mbox->state = OCTEON_MBOX_STATE_RESPONSE_PENDING; in octeon_mbox_write()
159 spin_unlock_irqrestore(&mbox->lock, flags); in octeon_mbox_write()
163 while (readq(mbox->mbox_write_reg) != OCTEON_PFVFSIG) { in octeon_mbox_write()
172 writeq(mbox_cmd->msg.u64, mbox->mbox_write_reg); in octeon_mbox_write()
173 for (i = 0; i < (u32)(mbox_cmd->msg.s.len - 1); i++) { in octeon_mbox_write()
175 while (readq(mbox->mbox_write_reg) != in octeon_mbox_write()
184 writeq(mbox_cmd->data[i], mbox->mbox_write_reg); in octeon_mbox_write()
190 spin_lock_irqsave(&mbox->lock, flags); in octeon_mbox_write()
191 if (mbox_cmd->msg.s.type == OCTEON_MBOX_RESPONSE) { in octeon_mbox_write()
192 mbox->state = OCTEON_MBOX_STATE_IDLE; in octeon_mbox_write()
193 writeq(OCTEON_PFVFSIG, mbox->mbox_read_reg); in octeon_mbox_write()
195 if ((!mbox_cmd->msg.s.resp_needed) || in octeon_mbox_write()
197 mbox->state &= ~OCTEON_MBOX_STATE_RESPONSE_PENDING; in octeon_mbox_write()
198 if (!(mbox->state & in octeon_mbox_write()
201 mbox->state = OCTEON_MBOX_STATE_IDLE; in octeon_mbox_write()
204 spin_unlock_irqrestore(&mbox->lock, flags); in octeon_mbox_write()
214 for (i = 0; i < oct->num_iqs; i++) { in get_vf_stats()
215 if (!oct->instr_queue[i]) in get_vf_stats()
217 stats->tx_packets += oct->instr_queue[i]->stats.tx_done; in get_vf_stats()
218 stats->tx_bytes += oct->instr_queue[i]->stats.tx_tot_bytes; in get_vf_stats()
221 for (i = 0; i < oct->num_oqs; i++) { in get_vf_stats()
222 if (!oct->droq[i]) in get_vf_stats()
224 stats->rx_packets += oct->droq[i]->stats.rx_pkts_received; in get_vf_stats()
225 stats->rx_bytes += oct->droq[i]->stats.rx_bytes_received; in get_vf_stats()
239 struct octeon_device *oct = mbox->oct_dev; in octeon_mbox_process_cmd()
241 switch (mbox_cmd->msg.s.cmd) { in octeon_mbox_process_cmd()
243 dev_dbg(&oct->pci_dev->dev, "got vfactive sending data back\n"); in octeon_mbox_process_cmd()
244 mbox_cmd->msg.s.type = OCTEON_MBOX_RESPONSE; in octeon_mbox_process_cmd()
245 mbox_cmd->msg.s.resp_needed = 1; in octeon_mbox_process_cmd()
246 mbox_cmd->msg.s.len = 2; in octeon_mbox_process_cmd()
247 mbox_cmd->data[0] = 0; /* VF version is in mbox_cmd->data[0] */ in octeon_mbox_process_cmd()
248 ((struct lio_version *)&mbox_cmd->data[0])->major = in octeon_mbox_process_cmd()
250 ((struct lio_version *)&mbox_cmd->data[0])->minor = in octeon_mbox_process_cmd()
252 ((struct lio_version *)&mbox_cmd->data[0])->micro = in octeon_mbox_process_cmd()
254 memcpy(mbox_cmd->msg.s.params, (uint8_t *)&oct->pfvf_hsword, 6); in octeon_mbox_process_cmd()
260 dev_info(&oct->pci_dev->dev, in octeon_mbox_process_cmd()
262 mbox->q_no); in octeon_mbox_process_cmd()
263 pcie_flr(oct->sriov_info.dpiring_to_vfpcidev_lut[mbox->q_no]); in octeon_mbox_process_cmd()
269 mbox_cmd->msg.s.params); in octeon_mbox_process_cmd()
273 dev_dbg(&oct->pci_dev->dev, "Got VF stats request. Sending data back\n"); in octeon_mbox_process_cmd()
274 mbox_cmd->msg.s.type = OCTEON_MBOX_RESPONSE; in octeon_mbox_process_cmd()
275 mbox_cmd->msg.s.resp_needed = 1; in octeon_mbox_process_cmd()
276 mbox_cmd->msg.s.len = 1 + in octeon_mbox_process_cmd()
278 get_vf_stats(oct, (struct oct_vf_stats *)mbox_cmd->data); in octeon_mbox_process_cmd()
298 spin_lock_irqsave(&mbox->lock, flags); in octeon_mbox_process_message()
300 if (mbox->state & OCTEON_MBOX_STATE_ERROR) { in octeon_mbox_process_message()
301 if (mbox->state & (OCTEON_MBOX_STATE_RESPONSE_PENDING | in octeon_mbox_process_message()
303 memcpy(&mbox_cmd, &mbox->mbox_resp, in octeon_mbox_process_message()
305 mbox->state = OCTEON_MBOX_STATE_IDLE; in octeon_mbox_process_message()
306 writeq(OCTEON_PFVFSIG, mbox->mbox_read_reg); in octeon_mbox_process_message()
307 spin_unlock_irqrestore(&mbox->lock, flags); in octeon_mbox_process_message()
310 mbox_cmd.fn(mbox->oct_dev, &mbox_cmd, in octeon_mbox_process_message()
315 mbox->state = OCTEON_MBOX_STATE_IDLE; in octeon_mbox_process_message()
316 writeq(OCTEON_PFVFSIG, mbox->mbox_read_reg); in octeon_mbox_process_message()
317 spin_unlock_irqrestore(&mbox->lock, flags); in octeon_mbox_process_message()
321 if (mbox->state & OCTEON_MBOX_STATE_RESPONSE_RECEIVED) { in octeon_mbox_process_message()
322 memcpy(&mbox_cmd, &mbox->mbox_resp, in octeon_mbox_process_message()
324 mbox->state = OCTEON_MBOX_STATE_IDLE; in octeon_mbox_process_message()
325 writeq(OCTEON_PFVFSIG, mbox->mbox_read_reg); in octeon_mbox_process_message()
326 spin_unlock_irqrestore(&mbox->lock, flags); in octeon_mbox_process_message()
329 mbox_cmd.fn(mbox->oct_dev, &mbox_cmd, mbox_cmd.fn_arg); in octeon_mbox_process_message()
333 if (mbox->state & OCTEON_MBOX_STATE_REQUEST_RECEIVED) { in octeon_mbox_process_message()
334 memcpy(&mbox_cmd, &mbox->mbox_req, in octeon_mbox_process_message()
337 mbox->state &= ~OCTEON_MBOX_STATE_REQUEST_RECEIVED; in octeon_mbox_process_message()
338 if (!(mbox->state & in octeon_mbox_process_message()
340 mbox->state = OCTEON_MBOX_STATE_IDLE; in octeon_mbox_process_message()
341 writeq(OCTEON_PFVFSIG, mbox->mbox_read_reg); in octeon_mbox_process_message()
344 spin_unlock_irqrestore(&mbox->lock, flags); in octeon_mbox_process_message()
349 spin_unlock_irqrestore(&mbox->lock, flags); in octeon_mbox_process_message()
357 struct octeon_mbox *mbox = oct->mbox[q_no]; in octeon_mbox_cancel()
361 spin_lock_irqsave(&mbox->lock, flags); in octeon_mbox_cancel()
362 mbox_cmd = &mbox->mbox_resp; in octeon_mbox_cancel()
364 if (!(mbox->state & OCTEON_MBOX_STATE_RESPONSE_PENDING)) { in octeon_mbox_cancel()
365 spin_unlock_irqrestore(&mbox->lock, flags); in octeon_mbox_cancel()
369 mbox->state = OCTEON_MBOX_STATE_IDLE; in octeon_mbox_cancel()
371 writeq(OCTEON_PFVFSIG, mbox->mbox_read_reg); in octeon_mbox_cancel()
372 spin_unlock_irqrestore(&mbox->lock, flags); in octeon_mbox_cancel()