drivers/net/wireless/realtek/rtlwifi/cam.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/realtek/rtlwifi/cam.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/realtek/rtlwifi/cam.c
Extension
.c
Size
8871 bytes
Lines
322
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (entry_i == 0) {
			target_content = (u32) (*(mac_addr + 0)) << 16 |
			    (u32) (*(mac_addr + 1)) << 24 | (u32) us_config;

			rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI],
					target_content);
			rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
					target_command);

			rtl_dbg(rtlpriv, COMP_SEC, DBG_LOUD,
				"WRITE %x: %x\n",
				rtlpriv->cfg->maps[WCAMI], target_content);
			rtl_dbg(rtlpriv, COMP_SEC, DBG_LOUD,
				"The Key ID is %d\n", entry_no);
			rtl_dbg(rtlpriv, COMP_SEC, DBG_LOUD,
				"WRITE %x: %x\n",
				rtlpriv->cfg->maps[RWCAM], target_command);

		} else if (entry_i == 1) {

			target_content = (u32) (*(mac_addr + 5)) << 24 |
			    (u32) (*(mac_addr + 4)) << 16 |
			    (u32) (*(mac_addr + 3)) << 8 |
			    (u32) (*(mac_addr + 2));

			rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI],
					target_content);
			rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
					target_command);

			rtl_dbg(rtlpriv, COMP_SEC, DBG_LOUD,
				"WRITE A4: %x\n", target_content);
			rtl_dbg(rtlpriv, COMP_SEC, DBG_LOUD,
				"WRITE A0: %x\n", target_command);

		} else {

			target_content =
			    (u32) (*(key_cont_128 + (entry_i * 4 - 8) + 3)) <<
			    24 | (u32) (*(key_cont_128 + (entry_i * 4 - 8) + 2))
			    << 16 |
			    (u32) (*(key_cont_128 + (entry_i * 4 - 8) + 1)) << 8
			    | (u32) (*(key_cont_128 + (entry_i * 4 - 8) + 0));

			rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI],
					target_content);
			rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
					target_command);

			rtl_dbg(rtlpriv, COMP_SEC, DBG_LOUD,
				"WRITE A4: %x\n", target_content);
			rtl_dbg(rtlpriv, COMP_SEC, DBG_LOUD,
				"WRITE A0: %x\n", target_command);
		}
	}

	rtl_dbg(rtlpriv, COMP_SEC, DBG_LOUD,
		"after set key, usconfig:%x\n", us_config);
}

u8 rtl_cam_add_one_entry(struct ieee80211_hw *hw, const u8 *mac_addr,
			 u32 ul_key_id, u32 ul_entry_idx, u32 ul_enc_alg,
			 u32 ul_default_key, u8 *key_content)
{
	u32 us_config;
	struct rtl_priv *rtlpriv = rtl_priv(hw);

	rtl_dbg(rtlpriv, COMP_SEC, DBG_DMESG,
		"EntryNo:%x, ulKeyId=%x, ulEncAlg=%x, ulUseDK=%x MacAddr %pM\n",
		ul_entry_idx, ul_key_id, ul_enc_alg,
		ul_default_key, mac_addr);

	if (ul_key_id == TOTAL_CAM_ENTRY) {
		rtl_dbg(rtlpriv, COMP_ERR, DBG_WARNING,
			"ulKeyId exceed!\n");
		return 0;
	}

	if (ul_default_key == 1)
		us_config = CFG_VALID | ((u16) (ul_enc_alg) << 2);
	else
		us_config = CFG_VALID | ((ul_enc_alg) << 2) | ul_key_id;

	rtl_cam_program_entry(hw, ul_entry_idx, mac_addr,
			      (u8 *)key_content, us_config);

	rtl_dbg(rtlpriv, COMP_SEC, DBG_DMESG, "end\n");

	return 1;

Annotation

Implementation Notes