	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_rx_alloc
_mtk_rx_alloc:                          ## @mtk_rx_alloc
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%esi, %r13d
	movq	%rdi, %r12
	movq	_MTK_RX_FLAGS_QDMA@GOTPCREL(%rip), %rax
	cmpl	%edx, (%rax)
	jne	LBB0_5
## %bb.1:
	testl	%r13d, %r13d
	je	LBB0_4
## %bb.2:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	jmp	LBB0_3
LBB0_5:
	movslq	%r13d, %rax
	imulq	$56, %rax, %r14
	addq	24(%r12), %r14
	xorl	%r15d, %r15d
	jmp	LBB0_6
LBB0_4:
	leaq	32(%r12), %r14
	movl	$4096, %r15d                    ## imm = 0x1000
LBB0_6:
	movq	_MTK_RX_FLAGS_HWLRO@GOTPCREL(%rip), %rax
	cmpl	%edx, (%rax)
	movq	_MTK_DMA_SIZE@GOTPCREL(%rip), %rax
	cmoveq	_MTK_HW_LRO_DMA_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	movq	_ETH_DATA_LEN@GOTPCREL(%rip), %rax
	cmoveq	_MTK_MAX_LRO_RX_LENGTH@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_mtk_max_frag_size
	movl	%eax, 48(%r14)
	movl	%eax, %edi
	callq	_mtk_max_buf_size
	movl	%eax, 24(%r14)
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movl	%ebx, %edi
	movl	$8, %esi
	callq	_kcalloc
	movq	%rax, 40(%r14)
	testq	%rax, %rax
	je	LBB0_11
## %bb.7:
	movq	%r15, -64(%rbp)                 ## 8-byte Spill
	movq	%rbx, -48(%rbp)                 ## 8-byte Spill
	testl	%ebx, %ebx
	jle	LBB0_12
## %bb.8:
	movl	-48(%rbp), %r15d                ## 4-byte Reload
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_10:                                ## =>This Inner Loop Header: Depth=1
	movl	48(%r14), %edi
	callq	_netdev_alloc_frag
	movq	40(%r14), %rcx
	movq	%rax, (%rcx,%rbx,8)
	testq	%rax, %rax
	je	LBB0_11
## %bb.9:                               ##   in Loop: Header=BB0_10 Depth=1
	incq	%rbx
	cmpq	%rbx, %r15
	jne	LBB0_10
LBB0_12:
	movl	8(%r12), %edi
	movq	-48(%rbp), %rbx                 ## 8-byte Reload
	leal	(,%rbx,8), %esi
	movq	_GFP_ATOMIC@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	%r14, %rdx
	callq	_dma_alloc_coherent
	movq	%rax, 32(%r14)
	testq	%rax, %rax
	je	LBB0_11
## %bb.13:
	movl	%r13d, -56(%rbp)                ## 4-byte Spill
	testl	%ebx, %ebx
	jle	LBB0_20
## %bb.14:
	movl	-48(%rbp), %r15d                ## 4-byte Reload
	xorl	%r13d, %r13d
	jmp	LBB0_15
	.p2align	4, 0x90
LBB0_18:                                ##   in Loop: Header=BB0_15 Depth=1
	movl	24(%r14), %edi
	callq	_RX_DMA_PLEN0
LBB0_19:                                ##   in Loop: Header=BB0_15 Depth=1
	movq	32(%r14), %rcx
	movl	%eax, 4(%rcx,%r13,8)
	incq	%r13
	cmpq	%r13, %r15
	je	LBB0_20
LBB0_15:                                ## =>This Inner Loop Header: Depth=1
	movl	8(%r12), %edi
	movq	40(%r14), %rax
	movq	_NET_SKB_PAD@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rsi
	addq	(%rax,%r13,8), %rsi
	addq	16(%r12), %rsi
	movl	24(%r14), %edx
	movq	_DMA_FROM_DEVICE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	callq	_dma_map_single
	movq	%rax, %rbx
	movl	8(%r12), %edi
	movq	%rax, %rsi
	callq	_dma_mapping_error
	movl	%eax, %edi
	callq	_unlikely
	testq	%rax, %rax
	jne	LBB0_11
## %bb.16:                              ##   in Loop: Header=BB0_15 Depth=1
	movq	32(%r14), %rax
	movl	%ebx, (%rax,%r13,8)
	movq	(%r12), %rax
	movl	(%rax), %edi
	movq	_MTK_SOC_MT7628@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_MTK_HAS_CAPS
	testq	%rax, %rax
	je	LBB0_18
## %bb.17:                              ##   in Loop: Header=BB0_15 Depth=1
	movq	_RX_DMA_LSO@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	jmp	LBB0_19
LBB0_11:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
LBB0_3:
	xorl	%r15d, %r15d
	subl	(%rax), %r15d
LBB0_21:
	movl	%r15d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_20:
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movl	%eax, 4(%r14)
	movl	$0, 8(%r14)
	decl	%eax
	movl	%eax, 12(%r14)
	movl	-56(%rbp), %ebx                 ## 4-byte Reload
	movl	%ebx, %edi
	callq	_MTK_PRX_CRX_IDX_CFG
	movq	%rax, 16(%r14)
	xorl	%r15d, %r15d
	xorl	%eax, %eax
	callq	_wmb
	movl	(%r14), %eax
	movl	%eax, -52(%rbp)                 ## 4-byte Spill
	movl	%ebx, %edi
	callq	_MTK_PRX_BASE_PTR_CFG
	movq	-64(%rbp), %r13                 ## 8-byte Reload
	leaq	(%rax,%r13), %rdx
	movq	%r12, %rdi
	movl	-52(%rbp), %esi                 ## 4-byte Reload
	callq	_mtk_w32
	movl	%ebx, %edi
	callq	_MTK_PRX_MAX_CNT_CFG
	leaq	(%rax,%r13), %rdx
	movq	%r12, %rdi
	movq	-48(%rbp), %rsi                 ## 8-byte Reload
                                        ## kill: def $esi killed $esi killed $rsi
	callq	_mtk_w32
	movl	12(%r14), %esi
	movq	16(%r14), %rdx
	addq	%r13, %rdx
	movq	%r12, %rdi
	callq	_mtk_w32
	movl	%ebx, %edi
	callq	_MTK_PST_DRX_IDX_CFG
	movq	_MTK_PDMA_RST_IDX@GOTPCREL(%rip), %rcx
	addq	(%rcx), %r13
	movq	%r12, %rdi
	movl	%eax, %esi
	movq	%r13, %rdx
	callq	_mtk_w32
	jmp	LBB0_21
	.cfi_endproc
                                        ## -- End function
	.comm	_MTK_RX_FLAGS_QDMA,4,2          ## @MTK_RX_FLAGS_QDMA
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_MTK_RX_FLAGS_HWLRO,4,2         ## @MTK_RX_FLAGS_HWLRO
	.comm	_MTK_MAX_LRO_RX_LENGTH,4,2      ## @MTK_MAX_LRO_RX_LENGTH
	.comm	_MTK_HW_LRO_DMA_SIZE,4,2        ## @MTK_HW_LRO_DMA_SIZE
	.comm	_ETH_DATA_LEN,4,2               ## @ETH_DATA_LEN
	.comm	_MTK_DMA_SIZE,4,2               ## @MTK_DMA_SIZE
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_GFP_ATOMIC,4,2                 ## @GFP_ATOMIC
	.comm	_NET_SKB_PAD,8,3                ## @NET_SKB_PAD
	.comm	_DMA_FROM_DEVICE,4,2            ## @DMA_FROM_DEVICE
	.comm	_MTK_SOC_MT7628,4,2             ## @MTK_SOC_MT7628
	.comm	_RX_DMA_LSO,4,2                 ## @RX_DMA_LSO
	.comm	_MTK_PDMA_RST_IDX,8,3           ## @MTK_PDMA_RST_IDX
	.no_dead_strip	_mtk_rx_alloc
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_rx_alloc
_mtk_rx_alloc:                          ; @mtk_rx_alloc
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x20, x1
	mov	x19, x0
Lloh0:
	adrp	x8, _MTK_RX_FLAGS_QDMA@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MTK_RX_FLAGS_QDMA@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	cmp	w8, w2
	b.ne	LBB0_3
; %bb.1:
	cbz	w20, LBB0_4
; %bb.2:
Lloh3:
	adrp	x8, _EINVAL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
	b	LBB0_19
LBB0_3:
	mov	x25, #0
	ldr	x8, [x19, #24]
	mov	w9, #56
	smaddl	x21, w20, w9, x8
	b	LBB0_5
LBB0_4:
	add	x21, x19, #32
	mov	w25, #4096
LBB0_5:
Lloh5:
	adrp	x8, _MTK_RX_FLAGS_HWLRO@GOTPAGE
Lloh6:
	ldr	x8, [x8, _MTK_RX_FLAGS_HWLRO@GOTPAGEOFF]
Lloh7:
	adrp	x9, _MTK_HW_LRO_DMA_SIZE@GOTPAGE
Lloh8:
	ldr	x9, [x9, _MTK_HW_LRO_DMA_SIZE@GOTPAGEOFF]
Lloh9:
	ldr	w8, [x8]
Lloh10:
	adrp	x10, _MTK_DMA_SIZE@GOTPAGE
Lloh11:
	ldr	x10, [x10, _MTK_DMA_SIZE@GOTPAGEOFF]
	cmp	w8, w2
	csel	x8, x9, x10, eq
	ldr	w22, [x8]
Lloh12:
	adrp	x8, _MTK_MAX_LRO_RX_LENGTH@GOTPAGE
Lloh13:
	ldr	x8, [x8, _MTK_MAX_LRO_RX_LENGTH@GOTPAGEOFF]
Lloh14:
	adrp	x9, _ETH_DATA_LEN@GOTPAGE
Lloh15:
	ldr	x9, [x9, _ETH_DATA_LEN@GOTPAGEOFF]
	csel	x8, x8, x9, eq
	ldr	w0, [x8]
	bl	_mtk_max_frag_size
	str	w0, [x21, #48]
	bl	_mtk_max_buf_size
	str	w0, [x21, #24]
Lloh16:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh17:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh18:
	ldr	w2, [x8]
	mov	x0, x22
	mov	w1, #8
	bl	_kcalloc
	str	x0, [x21, #40]
	cbz	x0, LBB0_18
; %bb.6:
	cmp	w22, #1
	b.lt	LBB0_10
; %bb.7:
	mov	x23, #0
	lsl	x24, x22, #3
LBB0_8:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x21, #48]
	bl	_netdev_alloc_frag
	ldr	x8, [x21, #40]
	str	x0, [x8, x23]
	cbz	x0, LBB0_18
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=1
	add	x23, x23, #8
	cmp	x24, x23
	b.ne	LBB0_8
LBB0_10:
	ldr	w0, [x19, #8]
	lsl	w1, w22, #3
Lloh19:
	adrp	x8, _GFP_ATOMIC@GOTPAGE
Lloh20:
	ldr	x8, [x8, _GFP_ATOMIC@GOTPAGEOFF]
Lloh21:
	ldr	w3, [x8]
	mov	x2, x21
	bl	_dma_alloc_coherent
	str	x0, [x21, #32]
	cbz	x0, LBB0_18
; %bb.11:
	str	x25, [sp, #8]                   ; 8-byte Folded Spill
	subs	w8, w22, #1
	str	w8, [sp, #4]                    ; 4-byte Folded Spill
	b.lt	LBB0_21
; %bb.12:
	mov	x26, #0
	lsl	x27, x22, #3
Lloh22:
	adrp	x28, _NET_SKB_PAD@GOTPAGE
Lloh23:
	ldr	x28, [x28, _NET_SKB_PAD@GOTPAGEOFF]
Lloh24:
	adrp	x25, _DMA_FROM_DEVICE@GOTPAGE
Lloh25:
	ldr	x25, [x25, _DMA_FROM_DEVICE@GOTPAGEOFF]
Lloh26:
	adrp	x24, _MTK_SOC_MT7628@GOTPAGE
Lloh27:
	ldr	x24, [x24, _MTK_SOC_MT7628@GOTPAGEOFF]
	b	LBB0_15
LBB0_13:                                ;   in Loop: Header=BB0_15 Depth=1
	ldr	w0, [x21, #24]
	bl	_RX_DMA_PLEN0
LBB0_14:                                ;   in Loop: Header=BB0_15 Depth=1
	ldr	x8, [x21, #32]
	add	x8, x8, x26
	str	w0, [x8, #4]
	add	x26, x26, #8
	cmp	x27, x26
	b.eq	LBB0_21
LBB0_15:                                ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x19, #8]
	ldr	x8, [x21, #40]
	ldr	x8, [x8, x26]
	ldr	x9, [x28]
	ldr	x10, [x19, #16]
	add	x8, x9, x8
	add	x1, x8, x10
	ldr	w2, [x21, #24]
	ldr	w3, [x25]
	bl	_dma_map_single
	mov	x23, x0
	ldr	w0, [x19, #8]
	mov	x1, x23
	bl	_dma_mapping_error
	bl	_unlikely
	cbnz	x0, LBB0_18
; %bb.16:                               ;   in Loop: Header=BB0_15 Depth=1
	ldr	x8, [x21, #32]
	str	w23, [x8, x26]
	ldr	x8, [x19]
	ldr	w0, [x8]
	ldr	w1, [x24]
	bl	_MTK_HAS_CAPS
	cbz	x0, LBB0_13
; %bb.17:                               ;   in Loop: Header=BB0_15 Depth=1
Lloh28:
	adrp	x8, _RX_DMA_LSO@GOTPAGE
Lloh29:
	ldr	x8, [x8, _RX_DMA_LSO@GOTPAGEOFF]
Lloh30:
	ldr	w0, [x8]
	b	LBB0_14
LBB0_18:
Lloh31:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh32:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
LBB0_19:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_20:
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_21:
	stp	w22, wzr, [x21, #4]
	ldr	w8, [sp, #4]                    ; 4-byte Folded Reload
	str	w8, [x21, #12]
	mov	x0, x20
	bl	_MTK_PRX_CRX_IDX_CFG
	str	x0, [x21, #16]
	bl	_wmb
	ldr	w23, [x21]
	mov	x0, x20
	bl	_MTK_PRX_BASE_PTR_CFG
	ldr	x24, [sp, #8]                   ; 8-byte Folded Reload
	add	x2, x0, x24
	mov	x0, x19
	mov	x1, x23
	bl	_mtk_w32
	mov	x0, x20
	bl	_MTK_PRX_MAX_CNT_CFG
	add	x2, x0, x24
	mov	x0, x19
	mov	x1, x22
	bl	_mtk_w32
	ldr	w1, [x21, #12]
	ldr	x8, [x21, #16]
	add	x2, x8, x24
	mov	x0, x19
	bl	_mtk_w32
	mov	x0, x20
	bl	_MTK_PST_DRX_IDX_CFG
	mov	x1, x0
Lloh33:
	adrp	x8, _MTK_PDMA_RST_IDX@GOTPAGE
Lloh34:
	ldr	x8, [x8, _MTK_PDMA_RST_IDX@GOTPAGEOFF]
Lloh35:
	ldr	x8, [x8]
	add	x2, x8, x24
	mov	x0, x19
	bl	_mtk_w32
	mov	w0, #0
	b	LBB0_20
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh9
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGot	Lloh26, Lloh27
	.loh AdrpLdrGot	Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpLdrGot	Lloh31, Lloh32
	.loh AdrpLdrGotLdr	Lloh33, Lloh34, Lloh35
	.cfi_endproc
                                        ; -- End function
	.comm	_MTK_RX_FLAGS_QDMA,4,2          ; @MTK_RX_FLAGS_QDMA
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_MTK_RX_FLAGS_HWLRO,4,2         ; @MTK_RX_FLAGS_HWLRO
	.comm	_MTK_MAX_LRO_RX_LENGTH,4,2      ; @MTK_MAX_LRO_RX_LENGTH
	.comm	_MTK_HW_LRO_DMA_SIZE,4,2        ; @MTK_HW_LRO_DMA_SIZE
	.comm	_ETH_DATA_LEN,4,2               ; @ETH_DATA_LEN
	.comm	_MTK_DMA_SIZE,4,2               ; @MTK_DMA_SIZE
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_GFP_ATOMIC,4,2                 ; @GFP_ATOMIC
	.comm	_NET_SKB_PAD,8,3                ; @NET_SKB_PAD
	.comm	_DMA_FROM_DEVICE,4,2            ; @DMA_FROM_DEVICE
	.comm	_MTK_SOC_MT7628,4,2             ; @MTK_SOC_MT7628
	.comm	_RX_DMA_LSO,4,2                 ; @RX_DMA_LSO
	.comm	_MTK_PDMA_RST_IDX,8,3           ; @MTK_PDMA_RST_IDX
	.no_dead_strip	_mtk_rx_alloc
.subsections_via_symbols
