1377                 return;
1378 
1379         ill_capability_send(ill, mp);
1380         ill->ill_dlpi_capab_state = IDCS_PROBE_SENT;
1381 }
1382 
1383 static boolean_t
1384 ill_capability_wait(ill_t *ill)
1385 {
1386         /*
1387          * I'm in this ill's squeue, aka a writer.  The ILL_CONDEMNED flag can
1388          * only be set by someone who is the writer.  Since we
1389          * drop-and-reacquire the squeue in this loop, we need to check for
1390          * ILL_CONDEMNED, which if set means nothing can signal our capability
1391          * condition variable.
1392          */
1393         ASSERT(IAM_WRITER_ILL(ill));
1394 
1395         while (ill->ill_capab_pending_cnt != 0 &&
1396             (ill->ill_state_flags & ILL_CONDEMNED) == 0) {
1397                 mutex_enter(&ill->ill_dlpi_capab_lock);
1398                 ipsq_exit(ill->ill_phyint->phyint_ipsq);
1399                 cv_wait(&ill->ill_dlpi_capab_cv, &ill->ill_dlpi_capab_lock);
1400                 mutex_exit(&ill->ill_dlpi_capab_lock);
1401                 /*
1402                  * If ipsq_enter() fails, someone set ILL_CONDEMNED
1403                  * while we dropped the squeue. Indicate such to the caller.
1404                  */
1405                 if (!ipsq_enter(ill, B_FALSE, CUR_OP))
1406                         return (B_FALSE);
1407         }
1408 
1409         return ((ill->ill_state_flags & ILL_CONDEMNED) == 0);
1410 }
1411 
1412 void
1413 ill_capability_reset(ill_t *ill, boolean_t reneg)
1414 {
1415         ASSERT(IAM_WRITER_ILL(ill));
1416 
1417         if (ill->ill_dlpi_capab_state != IDCS_OK)
1418                 return;
1419 
1420         ill->ill_dlpi_capab_state = reneg ? IDCS_RENEG : IDCS_RESET_SENT;
 
3496         rw_init(&ill->ill_mcast_lock, NULL, RW_DEFAULT, NULL);
3497         mutex_init(&ill->ill_mcast_serializer, NULL, MUTEX_DEFAULT, NULL);
3498         ill->ill_global_timer = INFINITY;
3499         ill->ill_mcast_v1_time = ill->ill_mcast_v2_time = 0;
3500         ill->ill_mcast_v1_tset = ill->ill_mcast_v2_tset = 0;
3501         ill->ill_mcast_rv = MCAST_DEF_ROBUSTNESS;
3502         ill->ill_mcast_qi = MCAST_DEF_QUERY_INTERVAL;
3503 
3504         /*
3505          * Initialize IPv6 configuration variables.  The IP module is always
3506          * opened as an IPv4 module.  Instead tracking down the cases where
3507          * it switches to do ipv6, we'll just initialize the IPv6 configuration
3508          * here for convenience, this has no effect until the ill is set to do
3509          * IPv6.
3510          */
3511         ill->ill_reachable_time = ND_REACHABLE_TIME;
3512         ill->ill_xmit_count = ND_MAX_MULTICAST_SOLICIT;
3513         ill->ill_max_buf = ND_MAX_Q;
3514         ill->ill_refcnt = 0;
3515 
3516         cv_init(&ill->ill_dlpi_capab_cv, NULL, CV_DEFAULT, NULL);
3517         mutex_init(&ill->ill_dlpi_capab_lock, NULL, MUTEX_DEFAULT, NULL);
3518 
3519         return (0);
3520 }
3521 
3522 /*
3523  * ill_init is called by ip_open when a device control stream is opened.
3524  * It does a few initializations, and shoots a DL_INFO_REQ message down
3525  * to the driver.  The response is later picked up in ip_rput_dlpi and
3526  * used to set up default mechanisms for talking to the driver.  (Always
3527  * called as writer.)
3528  *
3529  * If this function returns error, ip_open will call ip_close which in
3530  * turn will call ill_delete to clean up any memory allocated here that
3531  * is not yet freed.
3532  *
3533  * Note: ill_ipst and ill_zoneid must be set before calling ill_init.
3534  */
3535 int
3536 ill_init(queue_t *q, ill_t *ill)
3537 {
3538         int ret;
 
12918 
12919                 *mpp = mp;
12920                 mutex_exit(&ill->ill_lock);
12921                 return;
12922         }
12923         mutex_exit(&ill->ill_lock);
12924         ill_dlpi_dispatch(ill, mp);
12925 }
12926 
12927 void
12928 ill_capability_send(ill_t *ill, mblk_t *mp)
12929 {
12930         ill->ill_capab_pending_cnt++;
12931         ill_dlpi_send(ill, mp);
12932 }
12933 
12934 void
12935 ill_capability_done(ill_t *ill)
12936 {
12937         ASSERT(ill->ill_capab_pending_cnt != 0);
12938 
12939         ill_dlpi_done(ill, DL_CAPABILITY_REQ);
12940 
12941         ill->ill_capab_pending_cnt--;
12942         if (ill->ill_capab_pending_cnt == 0 &&
12943             ill->ill_dlpi_capab_state == IDCS_OK)
12944                 ill_capability_reset_alloc(ill);
12945 
12946         mutex_enter(&ill->ill_dlpi_capab_lock);
12947         cv_broadcast(&ill->ill_dlpi_capab_cv);
12948         mutex_exit(&ill->ill_dlpi_capab_lock);
12949 }
12950 
12951 /*
12952  * Send all deferred DLPI messages without waiting for their ACKs.
12953  */
12954 void
12955 ill_dlpi_send_deferred(ill_t *ill)
12956 {
12957         mblk_t *mp, *nextmp;
12958 
12959         /*
12960          * Clear ill_dlpi_pending so that the message is not queued in
12961          * ill_dlpi_send().
12962          */
12963         mutex_enter(&ill->ill_lock);
12964         ill->ill_dlpi_pending = DL_PRIM_INVAL;
12965         mp = ill->ill_dlpi_deferred;
12966         ill->ill_dlpi_deferred = NULL;
12967         mutex_exit(&ill->ill_lock);
12968 
 
 | 
 
 
1377                 return;
1378 
1379         ill_capability_send(ill, mp);
1380         ill->ill_dlpi_capab_state = IDCS_PROBE_SENT;
1381 }
1382 
1383 static boolean_t
1384 ill_capability_wait(ill_t *ill)
1385 {
1386         /*
1387          * I'm in this ill's squeue, aka a writer.  The ILL_CONDEMNED flag can
1388          * only be set by someone who is the writer.  Since we
1389          * drop-and-reacquire the squeue in this loop, we need to check for
1390          * ILL_CONDEMNED, which if set means nothing can signal our capability
1391          * condition variable.
1392          */
1393         ASSERT(IAM_WRITER_ILL(ill));
1394 
1395         while (ill->ill_capab_pending_cnt != 0 &&
1396             (ill->ill_state_flags & ILL_CONDEMNED) == 0) {
1397                 /* This may enable blocked callers of ill_capability_done(). */
1398                 ipsq_exit(ill->ill_phyint->phyint_ipsq);
1399                 /* Pause a bit (1msec) before we re-enter the squeue. */
1400                 delay(drv_usectohz(1000000));
1401 
1402                 /*
1403                  * If ipsq_enter() fails, someone set ILL_CONDEMNED
1404                  * while we dropped the squeue. Indicate such to the caller.
1405                  */
1406                 if (!ipsq_enter(ill, B_FALSE, CUR_OP))
1407                         return (B_FALSE);
1408         }
1409 
1410         return ((ill->ill_state_flags & ILL_CONDEMNED) == 0);
1411 }
1412 
1413 void
1414 ill_capability_reset(ill_t *ill, boolean_t reneg)
1415 {
1416         ASSERT(IAM_WRITER_ILL(ill));
1417 
1418         if (ill->ill_dlpi_capab_state != IDCS_OK)
1419                 return;
1420 
1421         ill->ill_dlpi_capab_state = reneg ? IDCS_RENEG : IDCS_RESET_SENT;
 
3497         rw_init(&ill->ill_mcast_lock, NULL, RW_DEFAULT, NULL);
3498         mutex_init(&ill->ill_mcast_serializer, NULL, MUTEX_DEFAULT, NULL);
3499         ill->ill_global_timer = INFINITY;
3500         ill->ill_mcast_v1_time = ill->ill_mcast_v2_time = 0;
3501         ill->ill_mcast_v1_tset = ill->ill_mcast_v2_tset = 0;
3502         ill->ill_mcast_rv = MCAST_DEF_ROBUSTNESS;
3503         ill->ill_mcast_qi = MCAST_DEF_QUERY_INTERVAL;
3504 
3505         /*
3506          * Initialize IPv6 configuration variables.  The IP module is always
3507          * opened as an IPv4 module.  Instead tracking down the cases where
3508          * it switches to do ipv6, we'll just initialize the IPv6 configuration
3509          * here for convenience, this has no effect until the ill is set to do
3510          * IPv6.
3511          */
3512         ill->ill_reachable_time = ND_REACHABLE_TIME;
3513         ill->ill_xmit_count = ND_MAX_MULTICAST_SOLICIT;
3514         ill->ill_max_buf = ND_MAX_Q;
3515         ill->ill_refcnt = 0;
3516 
3517         return (0);
3518 }
3519 
3520 /*
3521  * ill_init is called by ip_open when a device control stream is opened.
3522  * It does a few initializations, and shoots a DL_INFO_REQ message down
3523  * to the driver.  The response is later picked up in ip_rput_dlpi and
3524  * used to set up default mechanisms for talking to the driver.  (Always
3525  * called as writer.)
3526  *
3527  * If this function returns error, ip_open will call ip_close which in
3528  * turn will call ill_delete to clean up any memory allocated here that
3529  * is not yet freed.
3530  *
3531  * Note: ill_ipst and ill_zoneid must be set before calling ill_init.
3532  */
3533 int
3534 ill_init(queue_t *q, ill_t *ill)
3535 {
3536         int ret;
 
12916 
12917                 *mpp = mp;
12918                 mutex_exit(&ill->ill_lock);
12919                 return;
12920         }
12921         mutex_exit(&ill->ill_lock);
12922         ill_dlpi_dispatch(ill, mp);
12923 }
12924 
12925 void
12926 ill_capability_send(ill_t *ill, mblk_t *mp)
12927 {
12928         ill->ill_capab_pending_cnt++;
12929         ill_dlpi_send(ill, mp);
12930 }
12931 
12932 void
12933 ill_capability_done(ill_t *ill)
12934 {
12935         ASSERT(ill->ill_capab_pending_cnt != 0);
12936         ASSERT(IAM_WRITER_ILL(ill));
12937 
12938         ill_dlpi_done(ill, DL_CAPABILITY_REQ);
12939 
12940         ill->ill_capab_pending_cnt--;
12941         if (ill->ill_capab_pending_cnt == 0 &&
12942             ill->ill_dlpi_capab_state == IDCS_OK)
12943                 ill_capability_reset_alloc(ill);
12944 }
12945 
12946 /*
12947  * Send all deferred DLPI messages without waiting for their ACKs.
12948  */
12949 void
12950 ill_dlpi_send_deferred(ill_t *ill)
12951 {
12952         mblk_t *mp, *nextmp;
12953 
12954         /*
12955          * Clear ill_dlpi_pending so that the message is not queued in
12956          * ill_dlpi_send().
12957          */
12958         mutex_enter(&ill->ill_lock);
12959         ill->ill_dlpi_pending = DL_PRIM_INVAL;
12960         mp = ill->ill_dlpi_deferred;
12961         ill->ill_dlpi_deferred = NULL;
12962         mutex_exit(&ill->ill_lock);
12963 
 
 |