Lines Matching defs:ecp_instp
119 ecp_parse_rx_packet(char *buf, int len, ecp_instance_t *ecp_instp)
128 ECP_STAT_UPDATE(ecp_instp, ierrors, 1);
135 if (bcmp(ecp_instp->ecp_src_addr.ether_addr_octet,
143 if (ecp_ver != ecp_instp->ecp_version) {
150 (void) pthread_mutex_lock(&ecp_instp->ecp_tx_lock);
151 if (ntohs(ecpp->ecp_seq) == ecp_instp->ecp_ack_seq) {
152 ecp_instp->ecp_last_ack_seq = ntohs(ecpp->ecp_seq);
153 ecp_instp->ecp_tx_acked = B_TRUE;
154 (void) pthread_cond_signal(&ecp_instp->ecp_tx_cv);
157 ntohs(ecpp->ecp_seq), ecp_instp->ecp_ack_seq);
159 (void) pthread_mutex_unlock(&ecp_instp->ecp_tx_lock);
160 } else if (ecp_instp->ecp_subtype == ecp_type) {
161 if (ecp_instp->ecp_init_req_seq) {
162 ecp_instp->ecp_init_req_seq = B_FALSE;
163 ecp_instp->ecp_req_seq = ntohs(ecpp->ecp_seq);
164 } else if (ntohs(ecpp->ecp_seq) == ecp_instp->ecp_req_seq) {
168 (void) ecp_send_impl(ecp_instp, NULL, 0, B_FALSE);
171 ecp_instp->ecp_req_seq = ntohs(ecpp->ecp_seq);
175 (void) ecp_send_impl(ecp_instp, NULL, 0, B_FALSE);
180 ecp_instp->ecp_ulp_cb(ecp_instp->ecp_ulp_cb_arg,
181 ecp_instp->ecp_ack_seq, ECP_REQ, (char *)++ecpp, len);
185 ECP_STAT_UPDATE(ecp_instp, ierrors, 1);
225 ecp_instance_t *ecp_instp;
232 ecp_instp = calloc(sizeof (ecp_instance_t), 1);
233 if (ecp_instp == NULL) {
238 ecp_instp->ecp_subtype = subtype;
239 ecp_instp->ecp_version = ECP_VERSION;
241 ecp_instp->ecp_req_seq = -1;
242 ecp_instp->ecp_ack_seq = rand() % 0xffff;
243 ecp_instp->ecp_ether_type = ETHERTYPE_ECP;
244 ecp_instp->ecp_sockfd = sockfd;
245 ecp_instp->ecp_max_tx_attempts = num_of_tries;
246 ecp_instp->ecp_ulp_cb = ecp_ulp_cb;
247 ecp_instp->ecp_ulp_cb_arg = arg;
248 ecp_instp->ecp_init_req_seq = B_TRUE;
249 (void) pthread_mutex_init(&ecp_instp->ecp_tx_lock, NULL);
250 (void) pthread_cond_init(&ecp_instp->ecp_tx_cv, NULL);
251 ecp_instp->ecp_tx_acked = B_FALSE;
255 bcopy(dst_addr, ecp_instp->ecp_dst_addr.ether_addr_octet, ETHERADDRL);
256 bcopy(src_addr, ecp_instp->ecp_src_addr.ether_addr_octet, ETHERADDRL);
257 (void) pthread_create(&ecp_instp->ecp_process_thread, NULL,
258 ecp_inst_thr_process, (void *)ecp_instp);
261 return (ecp_instp);
267 ecp_instance_t *ecp_instp = instp;
270 (void) pthread_kill(ecp_instp->ecp_process_thread, SIGQUIT);
271 (void) pthread_join(ecp_instp->ecp_process_thread, NULL);
290 ecp_instance_t *ecp_instp = instp;
302 bcopy(&ecp_instp->ecp_dst_addr,
304 bcopy(&ecp_instp->ecp_src_addr,
307 htons(ecp_instp->ecp_ether_type);
309 (ecp_instp->ecp_version & ECP_VER_MASK) << ECP_VER_SHIFT;
311 (ecp_instp->ecp_subtype & ECP_SUBTYPE_MASK)
321 ecp_hdrp->ecp_seq = htons(ecp_instp->ecp_req_seq);
324 ecp_hdrp->ecp_seq = htons(++ecp_instp->ecp_ack_seq);
331 ret = send(ecp_instp->ecp_sockfd, (void *)ecp_hdrp, len, 0);
334 ECP_STAT_UPDATE(ecp_instp, oerrors, 1);
339 ECP_STAT_UPDATE(ecp_instp, rexmits, 1);
341 ECP_STAT_UPDATE(ecp_instp, opkts, 1);
352 ecp_instance_t *ecp_instp = instp;
357 (void) pthread_mutex_lock(&ecp_instp->ecp_tx_lock);
358 ecp_instp->ecp_tx_acked = B_FALSE;
359 while (retry_count < ecp_instp->ecp_max_tx_attempts) {
366 (void) pthread_cond_timedwait(&ecp_instp->ecp_tx_cv,
367 &ecp_instp->ecp_tx_lock, &next_time);
371 if (ecp_instp->ecp_tx_acked)
375 if (!ecp_instp->ecp_tx_acked)
376 ECP_STAT_UPDATE(ecp_instp, timeouts, 1);
377 ret = ecp_instp->ecp_tx_acked;
378 (void) pthread_mutex_unlock(&ecp_instp->ecp_tx_lock);
385 ecp_instance_t *ecp_instp = instp;
387 *es = ecp_instp->ecp_stat;
400 ecp_instance_t *ecp_instp = instp;
402 ecpc->ecpc_req_seq = ecp_instp->ecp_req_seq;
403 ecpc->ecpc_ack_seq = ecp_instp->ecp_ack_seq;
404 ecpc->ecpc_last_ack_seq = ecp_instp->ecp_last_ack_seq;
405 ecpc->ecpc_max_tx_attempts = ecp_instp->ecp_max_tx_attempts;