Lines Matching refs:dev

72 		struct iamt_heci_device *dev,
75 struct iamt_heci_device *dev,
77 static void heci_bh_read_bus_message(struct iamt_heci_device *dev,
80 struct iamt_heci_device *dev,
83 struct iamt_heci_device *dev,
85 static void heci_client_connect_response(struct iamt_heci_device *dev,
87 static void heci_client_disconnect_response(struct iamt_heci_device *dev,
89 static void heci_client_flow_control_response(struct iamt_heci_device *dev,
91 static void heci_client_disconnect_request(struct iamt_heci_device *dev,
94 static int heci_bh_process_device(struct iamt_heci_device *dev);
169 * @dev: Device object for our driver.
172 static void _heci_cmpl_iamthif(struct iamt_heci_device *dev,
175 if (dev->iamthif_canceled != 1) {
176 dev->iamthif_state = HECI_IAMTHIF_READ_COMPLETE;
177 dev->iamthif_stall_timer = 0;
179 dev->iamthif_msg_buf,
180 dev->iamthif_msg_buf_index);
182 &dev->pthi_read_complete_list.heci_cb.cb_list);
185 run_next_iamthif_cmd(dev);
187 if (&dev->iamthif_file_ext.pollwait) {
189 pollwakeup(&dev->iamthif_file_ext.pollwait, POLL_IN|POLLRDNORM);
203 struct iamt_heci_device *dev = (struct iamt_heci_device *)data;
206 while (heci_bh_process_device(dev))
209 if (heci_bh_process_device(dev)) {
210 PEPARE_WORK(&dev->work, heci_bh_handler);
212 rets = schedule_work(&dev->work);
226 heci_bh_process_device(struct iamt_heci_device *dev)
237 mutex_enter(&dev->device_lock);
238 heci_initialize_list(&complete_list, dev);
239 dev->host_hw_state = read_heci_register(dev, H_CSR);
240 dev->me_hw_state = read_heci_register(dev, ME_CSR_HA);
243 if (((dev->me_hw_state & ME_RDY_HRA) == 0) &&
244 (dev->heci_state != HECI_RESETING) &&
245 (dev->heci_state != HECI_INITIALIZING)) {
247 heci_reset(dev, 1);
248 mutex_exit(&dev->device_lock);
252 /* check if we need to start the dev */
253 if ((dev->host_hw_state & H_RDY) == 0) {
254 if ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA) {
255 DBG("we need to start the dev.\n");
256 dev->host_hw_state |= (H_IE | H_IG | H_RDY);
257 heci_set_csr_register(dev);
258 if (dev->heci_state == HECI_INITIALIZING) {
259 dev->recvd_msg = 1;
260 cv_broadcast(&dev->wait_recvd_msg);
261 mutex_exit(&dev->device_lock);
266 mutex_exit(&dev->device_lock);
267 if (dev->reinit_tsk &&
268 ddi_taskq_dispatch(dev->reinit_tsk,
270 dev, DDI_SLEEP) == DDI_FAILURE) {
279 heci_csr_enable_interrupts(dev);
280 mutex_exit(&dev->device_lock);
285 slots = count_full_read_slots(dev);
287 slots, dev->extra_write_index);
288 while ((slots > 0) && (!dev->extra_write_index)) {
290 dev->extra_write_index);
292 rets = heci_bh_read_handler(&complete_list, dev, &slots);
296 rets = heci_bh_write_handler(&complete_list, dev, &slots);
299 dev->host_hw_state = read_heci_register(dev, H_CSR);
300 dev->host_buffer_is_empty = host_buffer_is_empty(dev);
302 if ((dev->host_hw_state & H_IS) == H_IS) {
304 heci_csr_disable_interrupts(dev);
311 heci_csr_enable_interrupts(dev);
314 if (dev->recvd_msg) {
320 DBG("wake up dev->wait_recvd_msg\n");
321 cv_broadcast(&dev->wait_recvd_msg);
326 mutex_exit(&dev->device_lock);
330 mutex_exit(&dev->device_lock);
337 if (file_ext != &dev->iamthif_file_ext) {
341 } else if (file_ext == &dev->iamthif_file_ext) {
342 _heci_cmpl_iamthif(dev, cb_pos);
355 * @dev: Device object for our driver
362 struct iamt_heci_device *dev,
370 if (!dev->rd_msg_hdr) {
371 dev->rd_msg_hdr = read_heci_register(dev, ME_CB_RW);
376 heci_hdr = (struct heci_msg_hdr *)&dev->rd_msg_hdr;
379 if ((heci_hdr->reserved) || !(dev->rd_msg_hdr)) {
387 &dev->file_list, link, struct heci_file_private) {
397 if (&file_pos->link == &dev->file_list) {
413 heci_bh_read_bus_message(dev, heci_hdr);
416 dev->iamthif_file_ext.host_client_id) &&
417 (HECI_FILE_CONNECTED == dev->iamthif_file_ext.state) &&
418 (dev->iamthif_state == HECI_IAMTHIF_READING)) {
422 ret = heci_bh_read_pthi_message(cmpl_list, dev, heci_hdr);
428 ret = heci_bh_read_client_message(cmpl_list, dev, heci_hdr);
435 *slots = count_full_read_slots(dev);
436 dev->rd_msg_hdr = 0;
454 * @dev: Device object for our driver
457 static void heci_bh_read_bus_message(struct iamt_heci_device *dev,
473 buffer = (unsigned char *)dev->rd_msg_buf;
474 ASSERT(heci_hdr->length < sizeof (dev->rd_msg_buf));
475 heci_read_slots(dev, buffer, heci_hdr->length);
482 dev->version.major_version = HBM_MAJOR_VERSION;
483 dev->version.minor_version = HBM_MINOR_VERSION;
485 dev->version = version_res->me_max_version;
487 dev->recvd_msg = 1;
494 heci_client_connect_response(dev, connect_res);
496 cv_broadcast(&dev->wait_recvd_msg);
502 heci_client_disconnect_response(dev, disconnect_res);
504 cv_broadcast(&dev->wait_recvd_msg);
509 heci_client_flow_control_response(dev, flow_control);
519 for (i = 0; i < dev->num_heci_me_clients; i++) {
520 if (dev->me_clients[i].client_id ==
522 dev->me_clients[i].props =
528 dev->recvd_msg = 1;
533 (void) memcpy(dev->heci_me_clients,
535 dev->recvd_msg = 1;
539 dev->heci_state = HECI_DISABLED;
541 heci_reset(dev, 1);
548 heci_client_disconnect_request(dev, disconnect_req);
553 heci_hdr = (struct heci_msg_hdr *)&dev->ext_msg_buf[0];
560 (struct hbm_host_stop_request *)&dev->ext_msg_buf[1];
567 dev->extra_write_index = 2;
582 * @dev: Device object for our driver
589 struct iamt_heci_device *dev,
596 ASSERT(heci_hdr->me_addr == dev->iamthif_file_ext.me_client_id);
597 ASSERT(dev->iamthif_state == HECI_IAMTHIF_READING);
599 buffer = (unsigned char *)(dev->iamthif_msg_buf +
600 dev->iamthif_msg_buf_index);
601 ASSERT(sizeof (dev->iamthif_msg_buf) >=
602 (dev->iamthif_msg_buf_index + heci_hdr->length));
604 heci_read_slots(dev, buffer, heci_hdr->length);
606 dev->iamthif_msg_buf_index += heci_hdr->length;
613 if (!dev->iamthif_current_cb)
616 priv_cb = dev->iamthif_current_cb;
617 dev->iamthif_current_cb = NULL;
623 dev->iamthif_stall_timer = 0;
624 priv_cb->information = dev->iamthif_msg_buf_index;
626 if ((dev->iamthif_ioctl) && (file_ext == &dev->iamthif_file_ext)) {
629 if (&dev->iamthif_file_ext) {
661 * @dev: Device object for our driver
668 struct iamt_heci_device *dev,
676 if (!((dev->read_list.status == 0) &&
677 !list_empty(&dev->read_list.heci_cb.cb_list)))
681 &dev->read_list.heci_cb.cb_list, cb_list, struct heci_cb_private) {
704 heci_read_slots(dev, buffer,
735 heci_read_slots(dev, (unsigned char *)dev->rd_msg_buf,
738 *(uint32_t *)dev->rd_msg_buf);
747 * @dev: Device object for our driver.
753 _heci_bh_iamthif_read(struct iamt_heci_device *dev, int32_t *slots)
760 if (!heci_send_flow_control(dev, &dev->iamthif_file_ext)) {
764 dev->iamthif_state = HECI_IAMTHIF_READING;
765 dev->iamthif_flow_control_pending = 0;
766 dev->iamthif_msg_buf_index = 0;
767 dev->iamthif_msg_buf_size = 0;
768 dev->iamthif_stall_timer = IAMTHIF_STALL_TIMER;
769 dev->host_buffer_is_empty = host_buffer_is_empty(dev);
780 * @dev: Device object for our driver.
789 _heci_bh_close(struct iamt_heci_device *dev, int32_t *slots,
799 if (!heci_disconnect(dev, file_ext)) {
810 &dev->ctrl_rd_list.heci_cb.cb_list);
824 * @dev: Device object for our driver.
833 _heci_bh_read(struct iamt_heci_device *dev, int32_t *slots,
842 if (!heci_send_flow_control(dev, file_ext)) {
850 &dev->read_list.heci_cb.cb_list);
865 * @dev: Device object for our driver.
874 _heci_bh_ioctl(struct iamt_heci_device *dev, int32_t *slots,
886 if (!heci_connect(dev, file_ext)) {
893 &dev->ctrl_rd_list.heci_cb.cb_list);
908 * @dev: Device object for our driver.
917 _heci_bh_cmpl(struct iamt_heci_device *dev, int32_t *slots,
927 heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
944 if (!heci_write_message(dev, heci_hdr,
953 flow_ctrl_reduce(dev, file_ext);
957 &dev->write_waiting_list.heci_cb.cb_list);
959 } else if (*slots == ((dev->host_hw_state & H_CBD) >> 24)) {
961 heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
971 if (!heci_write_message(dev, heci_hdr,
1001 * @dev: Device object for our driver.
1010 _heci_bh_cmpl_iamthif(struct iamt_heci_device *dev, int32_t *slots,
1020 dev->iamthif_msg_buf_size -
1021 dev->iamthif_msg_buf_index)) {
1022 heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
1025 heci_hdr->length = dev->iamthif_msg_buf_size -
1026 dev->iamthif_msg_buf_index;
1033 if (!heci_write_message(dev, heci_hdr,
1034 (dev->iamthif_msg_buf +
1035 dev->iamthif_msg_buf_index),
1037 dev->iamthif_state = HECI_IAMTHIF_IDLE;
1042 flow_ctrl_reduce(dev, file_ext);
1043 dev->iamthif_msg_buf_index += heci_hdr->length;
1044 priv_cb_pos->information = dev->iamthif_msg_buf_index;
1046 dev->iamthif_state = HECI_IAMTHIF_FLOW_CONTROL;
1047 dev->iamthif_flow_control_pending = 1;
1049 dev->iamthif_current_cb = priv_cb_pos;
1051 &dev->write_waiting_list.heci_cb.cb_list);
1054 } else if (*slots == ((dev->host_hw_state & H_CBD) >> 24)) {
1056 heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
1067 if (!heci_write_message(dev, heci_hdr,
1068 (dev->iamthif_msg_buf +
1069 dev->iamthif_msg_buf_index),
1074 dev->iamthif_msg_buf_index += heci_hdr->length;
1089 * @dev: Device object for our driver
1096 struct iamt_heci_device *dev,
1105 if (!host_buffer_is_empty(dev)) {
1109 dev->write_hang = (uint8_t)-1;
1110 *slots = count_empty_write_slots(dev);
1114 list = &dev->write_waiting_list;
1127 (file_ext != &dev->iamthif_file_ext)) {
1134 if (file_ext == &dev->iamthif_file_ext) {
1136 if (dev->iamthif_flow_control_pending) {
1137 ret = _heci_bh_iamthif_read(dev,
1148 if ((dev->stop) && (!dev->wd_pending)) {
1149 dev->wd_stoped = 1;
1150 cv_broadcast(&dev->wait_stop_wd);
1154 if (dev->extra_write_index != 0) {
1155 DBG("extra_write_index =%d.\n", dev->extra_write_index);
1156 if (!heci_write_message(dev,
1157 (struct heci_msg_hdr *)&dev->ext_msg_buf[0],
1158 (unsigned char *)&dev->ext_msg_buf[1],
1159 (dev->extra_write_index - 1) * sizeof (uint32_t))) {
1162 *slots -= dev->extra_write_index;
1163 dev->extra_write_index = 0;
1165 if (dev->heci_state == HECI_ENABLED) {
1166 if (dev->wd_pending &&
1167 flow_ctrl_creds(dev, &dev->wd_file_ext)) {
1168 if (!heci_send_wd(dev)) {
1171 flow_ctrl_reduce(dev, &dev->wd_file_ext);
1173 dev->wd_pending = 0;
1175 if (dev->wd_timeout != 0) {
1178 dev->wd_due_counter = 2;
1182 dev->wd_due_counter = 0;
1187 if (dev->stop)
1191 if (dev->ctrl_wr_list.status == 0) {
1195 &dev->ctrl_wr_list.heci_cb.cb_list,
1206 ret = _heci_bh_close(dev, slots,
1215 ret = _heci_bh_read(dev, slots,
1224 if (!other_client_is_connecting(dev, file_ext))
1226 ret = _heci_bh_ioctl(dev, slots,
1241 if ((dev->write_list.status == 0) &&
1242 !list_empty(&dev->write_list.heci_cb.cb_list)) {
1246 &dev->write_list.heci_cb.cb_list,
1252 if (file_ext != &dev->iamthif_file_ext) {
1253 if (!flow_ctrl_creds(dev, file_ext)) {
1260 ret = _heci_bh_cmpl(dev, slots,
1265 } else if (file_ext == &dev->iamthif_file_ext) {
1268 if (!flow_ctrl_creds(dev, file_ext)) {
1275 ret = _heci_bh_cmpl_iamthif(dev, slots,
1295 * @dev: Device object for our driver
1325 * @dev: Device object for our driver
1329 heci_client_connect_response(struct iamt_heci_device *dev,
1338 if ((is_treat_specially_client(&(dev->wd_file_ext), rs)) ||
1339 (is_treat_specially_client(&(dev->iamthif_file_ext), rs)))
1342 if (dev->ctrl_rd_list.status == 0 &&
1343 !list_empty(&dev->ctrl_rd_list.heci_cb.cb_list)) {
1346 &dev->ctrl_rd_list.heci_cb.cb_list,
1370 * @dev: Device object for our driver
1373 static void heci_client_disconnect_response(struct iamt_heci_device *dev,
1379 if (dev->ctrl_rd_list.status == 0 &&
1380 !list_empty(&dev->ctrl_rd_list.heci_cb.cb_list)) {
1383 &dev->ctrl_rd_list.heci_cb.cb_list,
1435 add_single_flow_creds(struct iamt_heci_device *dev,
1441 for (i = 0; i < dev->num_heci_me_clients; i++) {
1442 client = &dev->me_clients[i];
1460 * @dev: Device object for our driver
1464 heci_client_flow_control_response(struct iamt_heci_device *dev,
1472 add_single_flow_creds(dev, flow_control);
1476 &dev->file_list, link, struct heci_file_private) {
1517 * @dev: Device object for our driver.
1521 heci_client_disconnect_request(struct iamt_heci_device *dev,
1529 list_for_each_entry_safe(file_pos, file_next, &dev->file_list,
1538 if (file_pos == &dev->wd_file_ext) {
1539 dev->wd_due_counter = 0;
1540 dev->wd_pending = 0;
1541 } else if (file_pos == &dev->iamthif_file_ext)
1542 dev->iamthif_timer = 0;
1546 (struct heci_msg_hdr *)&dev->ext_msg_buf[0];
1556 &dev->ext_msg_buf[1];
1562 dev->extra_write_index = 2;
1578 struct iamt_heci_device *dev = (struct iamt_heci_device *)data;
1581 mutex_enter(&dev->device_lock);
1582 if (dev->heci_state != HECI_ENABLED) {
1583 dev->wd_timer = timeout(heci_wd_timer, data, 2 * HZ);
1584 mutex_exit(&dev->device_lock);
1587 if (dev->wd_file_ext.state != HECI_FILE_CONNECTED) {
1588 dev->wd_timer = timeout(heci_wd_timer, data, 2 * HZ);
1589 mutex_exit(&dev->device_lock);
1593 if ((dev->wd_due_counter != 0) && (dev->wd_bypass == 0)) {
1594 if (--dev->wd_due_counter == 0) {
1595 if (dev->host_buffer_is_empty &&
1596 flow_ctrl_creds(dev, &dev->wd_file_ext)) {
1597 dev->host_buffer_is_empty = 0;
1598 if (!heci_send_wd(dev)) {
1601 flow_ctrl_reduce(dev,
1602 &dev->wd_file_ext);
1605 if (dev->wd_timeout != 0)
1606 dev->wd_due_counter = 2;
1608 dev->wd_due_counter = 0;
1611 dev->wd_pending = 1;
1615 if (dev->iamthif_stall_timer != 0) {
1616 if (--dev->iamthif_stall_timer == 0) {
1618 heci_reset(dev, 1);
1619 dev->iamthif_msg_buf_size = 0;
1620 dev->iamthif_msg_buf_index = 0;
1621 dev->iamthif_canceled = 0;
1622 dev->iamthif_ioctl = 1;
1623 dev->iamthif_state = HECI_IAMTHIF_IDLE;
1624 dev->iamthif_timer = 0;
1625 mutex_exit(&dev->device_lock);
1627 if (dev->iamthif_current_cb)
1628 heci_free_cb_private(dev->iamthif_current_cb);
1630 mutex_enter(&dev->device_lock);
1631 dev->iamthif_file_object = NULL;
1632 dev->iamthif_current_cb = NULL;
1633 run_next_iamthif_cmd(dev);
1636 dev->wd_timer = timeout(heci_wd_timer, data, 2 * HZ);
1637 mutex_exit(&dev->device_lock);