* Look up the workstream given a packet and source identifier. Do this by * checking the protocol's policy, and optionally call out to the protocol * for assistance if required. */
| 790 | * for assistance if required. |
| 791 | */ |
| 792 | static struct mbuf * |
| 793 | netisr_select_cpuid(struct netisr_proto *npp, u_int dispatch_policy, |
| 794 | uintptr_t source, struct mbuf *m, u_int *cpuidp) |
| 795 | { |
| 796 | struct ifnet *ifp; |
| 797 | u_int policy; |
| 798 | |
| 799 | NETISR_LOCK_ASSERT(); |
| 800 | |
| 801 | /* |
| 802 | * In the event we have only one worker, shortcut and deliver to it |
| 803 | * without further ado. |
| 804 | */ |
| 805 | if (nws_count == 1) { |
| 806 | *cpuidp = nws_array[0]; |
| 807 | return (m); |
| 808 | } |
| 809 | |
| 810 | /* |
| 811 | * What happens next depends on the policy selected by the protocol. |
| 812 | * If we want to support per-interface policies, we should do that |
| 813 | * here first. |
| 814 | */ |
| 815 | policy = npp->np_policy; |
| 816 | if (policy == NETISR_POLICY_CPU) { |
| 817 | m = npp->np_m2cpuid(m, source, cpuidp); |
| 818 | if (m == NULL) |
| 819 | return (NULL); |
| 820 | |
| 821 | /* |
| 822 | * It's possible for a protocol not to have a good idea about |
| 823 | * where to process a packet, in which case we fall back on |
| 824 | * the netisr code to decide. In the hybrid case, return the |
| 825 | * current CPU ID, which will force an immediate direct |
| 826 | * dispatch. In the queued case, fall back on the SOURCE |
| 827 | * policy. |
| 828 | */ |
| 829 | if (*cpuidp != NETISR_CPUID_NONE) { |
| 830 | *cpuidp = netisr_get_cpuid(*cpuidp); |
| 831 | return (m); |
| 832 | } |
| 833 | if (dispatch_policy == NETISR_DISPATCH_HYBRID) { |
| 834 | *cpuidp = netisr_get_cpuid(curcpu); |
| 835 | return (m); |
| 836 | } |
| 837 | policy = NETISR_POLICY_SOURCE; |
| 838 | } |
| 839 | |
| 840 | if (policy == NETISR_POLICY_FLOW) { |
| 841 | if (M_HASHTYPE_GET(m) == M_HASHTYPE_NONE && |
| 842 | npp->np_m2flow != NULL) { |
| 843 | m = npp->np_m2flow(m, source); |
| 844 | if (m == NULL) |
| 845 | return (NULL); |
| 846 | } |
| 847 | if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) { |
| 848 | *cpuidp = |
| 849 | netisr_default_flow2cpu(m->m_pkthdr.flowid); |
no test coverage detected