San Francisco 49ers coach Kyle Shanahan understood why linebacker Dre Greenlaw drew a penalty for unnecessary roughness after a helmet-to-helmet hit on Los Angeles Chargers quarterback Justin Herbert late in the first half of Sunday night's game.

But even after his team emerged with a 22-16 victory to improve to 5-4, Shanahan said he didn't think Greenlaw should have been ejected and was still befuddled as to why that decision was made.

"It kind of actually blew my mind," Shanahan said.